V
V
Vlad1612014-06-26 11:08:18
Java
Vlad161, 2014-06-26 11:08:18

What is wrong in my code, and how can I improve my skills?

I sent a test task to the position of Android developer, but in response they wrote:

After reviewing the test task, we noted that you have an insufficient level of knowledge of OOP principles and the principles of building Android applications.
If you improve your level of knowledge, learn more about OOP and how to apply its principles to building applications, then we could return to the issue of considering your candidacy in the future.

I am self-taught, I learned from books, articles, etc. , can you see with an experienced eye what is wrong in my code in terms of OOP and construction principles? And how do you upgrade these skills?
Code on gitHub, because not one or two classes https://github.com/Vlad161/Products

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
one pavel, 2014-06-26
@Vlad161

You have written everything correctly.
My advice to you is to go to github, download projects from there and watch their mechanics.
Before hacking the code, we look at the source data.
You have this json, open it and look.
We see an array of identical objects. For our convenience
, let's think of a class for json data

class Product {
int id;
String name;
String picture;
String description;
}

Now we need to parse them into a list in the activity.
Do you have an object with a method
which returns a json array, and if the customer gives two such files tomorrow!?
we don’t want to copy-paste, but we’ll do it universally and the parser method will immediately return an array of objects, not json data, and then we will throw out unnecessary entities
ArrayList<String> nameList = new ArrayList<String>();
ArrayList<Integer> idList = new ArrayList<Integer>();

and insert only one list
and then we will receive data
Let's make readJsonFromAsset static, since JSONReadFromAsset does not carry anything in itself.
readJsonFromAsset should have something like this
readJsonFromAsset() {
List<Product> dataList = new LinkedList();
for () {
Product product = new Product();
obj = jsonArray.getJSONObject(position);
product.id = obj.getInt("id");
product.name = obj.getString("name");
product.description = obj.getString("description");
product.picture = obj.getString("picture");
dataList.add(product);
}
return dataList; 
}

instead of the getString, getInt methods, I prefer to use optString, optInt
There are many options for parsing data, you can dodge it in different ways.
And to show that you are cool, you can make the Product Parcelable class
and not pass a bunch of lines through the bundle in the intent, but transfer the Product object right away.
In another activity, accept and work with it.
You can do this
public static final String LINK = " ironwaterstudio.com ";
and put in an easily accessible place or have a separate class
class Static {
public static final String LINK =  "http://ironwaterstudio.com";
}

AlertDialog - how much you need to process setNegativeButton, try not to pass the button handler, but put null

H
hummerd, 2014-07-03
@hummerd

What books did you study? Have you read the classic?
Steve McConnell Code Complete = Code complete. - St. Petersburg: Peter, 2005. - S. 896. - (Master class). — ISBN 5-7502-0064-7, 5-469-00822-3
Martin Fowler Patterns of Enterprise Application Architecture (Addison-Wesley Signature Series). - M .: "Williams", 2012. - 544 p. — ISBN 978-5-8459-1611-2
E. Gamma, R. Helm, R. Johnson, J. Vlissides Object Oriented Design Techniques. Design Patterns = Design Patterns: Elements of Reusable Object-Oriented Software. - St. Petersburg: "Peter", 2007. - S. 366. - ISBN 978-5-469-01136-1 (also ISBN 5-272-00355-1)
Gradi Butch, Robert A Maksimchuk. Object-Oriented Analysis and Design with Sample Applications (3rd edition) 2008 ISBN: 978-5-8459-1401-9

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question