pokemondex's Issues
Code Review
Desacoplamento
Primeiramente, parabéns pelo desempenho que tu teve Nillia, apesar de parecer simples eu sei que você teve muito trabalho!
Na linha de código seguinte, presente no arquivo API.swift, temos que o trecho de código que deveria está em um arquivo separado (model) se encontra dentro de outro.
PokemonDex/PokemonDex/Service/API.swift
Lines 10 to 22 in 5c78b84
Para desacoplar essa sequencia de código devemos criar um novo arquivo .swift, basta apertar "cmd + n", escolher a opção swift file e nomear como uma model (ex: DataModel).
Outro arquivo que necessita de um desacoplamento é o ViewController.swift, esse é bem mais rápido já que você não precisará que criar um novo arquivo. Tendo o seguinte trecho de código:
class ViewController: UIViewController, UISearchResultsUpdating {
//busca da search bar
func updateSearchResults(for searchController: UISearchController) {
guard let text = searchController.searchBar.text else {
return
}
print(text)
}
Podemos desacoplar o protocolo UISearchResultsUpdating
utilizando um extension
e trazendo a func dele para dentro desse extension
CodeExemple do review anterior:
extension ViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
guard let text = searchController.searchBar.text else {
return
}
}
Trabalhando nos apontamentos feitos, seu código se tornará mais legível, desacoplado, e padronizado. Voltando a inteirar parabéns por ter indo em frente com o projeto e não desistido 💯
Olá Nillia, seu projeto ficou bem legal, dá para notar que você se empenhou nele!
Percebi que você deixou todas as funções dos métodos da sua ViewController em apenas um lugar. Da seguinte forma:
PokemonDex/PokemonDex/View/CardSaveViewController.swift
Lines 56 to 73 in b9bc3b4
Ficaria melhor organizado, bem como maia fácil de ler, se você fizesse uma extensão da sua classe para método.
Aqui um exemplo de como ficariam as extensões com seus respectivos métodos e func:
extension CardSaveViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataSave.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CardUICell
cell.configFromCoreData(with: dataSave[indexPath.row])
cell.removeButton()
return cell
}
}
extension CardSaveViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
print(dataSave[indexPath.row].url ?? "")
}
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.