• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

clean code

 
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am more o less able to code, solving more o less simple problems.
My problem solving strategy is one, I go  progressively one step back from the expected result to what I can do,
and in this way I come up with an algorithm,  then later new features are introduced in my sw and I keep going to insert IF conditions and I put everywhere
in the code flag Boolean conditions false and true, so that when I start the program they are maintained in memory.

This causes that every time my code is seen, the Lead Developers prefer to hire fellow guys that can write simple and testable code. I read a good coder have to be dumb and lazy, but I make everything complex because of my strange character.

Do you have some recommendation to write better code? I mean trying to make elegant algorithms and avoid all the IF, Else IF (true that) Else IF is true that or is false the other one) etc.

When I review my own code after months, I need really to make a lot of effort to understand what is going on.

Of course complaining is not the way to go, so I started to study Mocks, Dependency Injection Android Frameworks( Java), Functional RX libraries, I begon to do TDD(this helps a lot), refactoring methods with extractions, some singleton to make classes a bit smaller, write method names self explicative but......
my problem is that if I have a problem I end up with IF structure nested 6 or 7 times that my self would be shamed if somebody should receive it one day as legacy code.
An example will make things clear:
given a String with n elements(aka letters) if A occurs in the first and/or second position then return  the String without the A in the first and or second position
ex.
ABCA ---> BCA  
AABCDA --->BCDA
DAUA---->DUA

I would start from the first condition you see, the most simple and model logic oriented, writing an IF, Then to match the second one I will wrap with a second IF, and if things get complex I would put a state Boolean flag variable as False or True to take control of the code, that will always less look like OO code, and will be always more functional in the meaning of the old programs of C64 in Basic where every line was giving a different sequential instruction

I tried to study Design Patterns, like Strategy, Observer, Factory, Decorator, Facade, Singleton, but still in real life I cannot think in these terms. And I would love to have my code in different packages with small classes with SOLID principles, separation of concern, no dependencies, inversion of control, cool libraries annotations and test super easy and clean
DO you have some recommendation that could help me to bridge this gap? my huge challenge is that I work alone, so I do not do Never code reviews, so I have not clue what should be improved, is like I do not have a real feedback to build up experience, chunk of valid knowledge if not my common sense that more o less I see improvements.
Thank you

 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at a recent reply I gave here: https://coderanch.com/t/672595/java/arrays#3146409

The first two books listed in that response will help you a lot, as will the books in the rest of that list.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Have a look at a recent reply I gave here: https://coderanch.com/t/672595/java/arrays#3146409

The first two books listed in that response will help you a lot, as will the books in the rest of that list.


THANK you i go immediately to find this out.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Have a look at a recent reply I gave here: https://coderanch.com/t/672595/java/arrays#3146409

The first two books listed in that response will help you a lot, as will the books in the rest of that list.


After I read your post, I need to come back to you.
First I see you have an Android tag as first, so even if good coding is a framework, mindset, still Android has some particularities, as Context, really complex SDK classes, Jack Wharton libraries that are now the standard de facto, Kotlin, RXJava just to mention some of them. Few friend that recommended me clean code, the book you tag as second, told me about these particularities of Android and the need to more specific tecniques, mocking with mockito for instance.

Second point is over the fact that it would be worthy to have a place in the web where to discuss of Android under the hood, understanding the mechanism behind, because this is the way people master concepts and at the moment the android world resource, namely SO is oriented mainly to give reply to specific problems, and learners curious do not have a friendly impact with all the rules, downvotes, blocked posts.
I was 2 times downvoted for instance only because I wanted to understand better how onCreate in Activity works, because there are people that need to acquire badges  downvoting, and do things really fast, to accumulate reputation I am saying that because you said that you learned a lot from this forum, and I find a bit challenging to do that because for instance in the forum there are really few post on Dagger 2 and RXJava that is what today developers most use, I really hope to see soon an Android forum for beginners, and one more advanced, where there is more than solving coding problems, but where understanding advanced Android concepts become the rule, in the pacific and relaxing atmosphere of this great place. After all if Java scores high in the Tiobe index is because of Android.

Thank you again for your insightful advices. I would like to say something about Aikido, being a professional martial artist.

1)KI
To code I need energy, I am un "uke" i receive information, I tryied the metodo pomodoro and every 25 minutes I see some tv series, or a railway program, or read some, I always rest before to get tired and in this way I can manage to do coding after my official financial job every day
2)Focus
The most important lesson I learned, the centralization.  Just think over the Torvalds PC, no distractions, no graphical interfaces.

3)Respect for Nage the thrower.
Do not fight with complexity in  the coding, have always a positive mindset,  there is a dinamic ball where a concept can fit, seeing the  fun puzzle to solve, not the task to do. Because coding is fun



 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CodeRanch has an Android forum under the heading Mobile, and I have added this thread to it.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:CodeRanch has an Android forum under the heading Mobile, and I have added this thread to it.


I know and it is a nice forum, but should be called Android Beginning imo. You cannot find  ANY discussion about Kotlin, RXJava, Dagger2 or Android specific architectural issues, Gradle, Mockito, Espresso and specific testing!  hile these  are topics all the Dev Android conferences have in agenda, and furthermore daily bread of every dev mobile engineer.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not start a discussion about those things?  It seems like the place to do it.
 
Giovanni Montano
Ranch Hand
Posts: 606
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Knute Snortum wrote:Why not start a discussion about those things?  It seems like the place to do it.


I tried several times

here even asking in advance if I could post, because I knew was a general senior question
https://coderanch.com/t/670498/dagger


For instance the first post of the year is a book presentation with 19 (one row posts)that say congratulation!

The second most voted as best of the year goes over AsyncTask, that is considered almost deprecated( complex multithread request to the servers are now standard managed by retrofit2+rxJava that now is rxJava2)
I knew a guy in a multinational that have to work out 10k methods because is legacy code and they still use it, but still you would not expect to see as best this year at the second place AsyncTask discussions, even because is a really trivial one, that does not add any knowledge to one that studied 5 min to the official documentation, you can see I closed the post suggesting an interesting reading
(to stimulate discussion over the peculiar android multithread, and to learn as you rightly pointed out), but is closed there,
https://coderanch.com/t/667044/mobile/pass-parameters-handler-Asynctask

the third best post of the year is over skills required to write android apps(?) and a website(??) . A google research would have been wiser:),  and despite this, in  all the post you cannot find the word JSON and RESTful as recommendation, Although 98% of the webservices implement these technologies in the mobile world!
https://coderanch.com/t/661311/mobile/Skills-required-website-android-app


Again forth best of the year is over changing an eclipse theme.  It is the 4th of the  best of the year, while are more than 2 years google do not develop SDK for Eclipse anymore!


At the moment a senior would be tempted to not go on the forum because  in SO you find the same newbe level of questions with a lot of solutions even upvoted, business fast alike, and  also you can find 99 per cent  of the  advanced topics, but not in sequential logical discussions like shines this forum, with calm, trying to understand together in the name of the love and enthusiasm we have for this profession/hobby, but really fast, without really considering the overall discussion, impersonally because there are milion of contributions in the light of making reputation higher, and topics  are downvoted and cancelled if instead of being problem related, could instead stimulate discussion(because can lead to advertise etc), instead here discussion is the key, and this is the strong and unvaluable value of this amazing forum. friendly environment, room to discuss, knowing each other better, relaxing in the off topic forums.

Just think over speaking about NPE in this forum in general and there., where you find thousands of solution saying change this or that given an example of code, but not somebody that make you understand where NPE comes from, how to prevent, what means in a broader sense.

I like the moderators here, and I really think they do a great volunteer job, especially if we consider this as a basic android forum, I just I think the solution should be to ask ourselves how is possible to bring some senior to help the community inside the forum, and stimulate more and more talented coders to go here. I think the solution is offer to them room to learn, outside helping the community, even because the mobile android world is one of the fastest changing, and every coder have to dedicate at least 5 hours self study per week to keep  herself updated.( This is another reason why a more senior forum would be really win-win for everyone). Personally at the moment coding is an hobby, I even cannot find a job because of terrible coding style, otherwise I would be happy to help, as occasionally I do for easy questions( sometimes I just google what is asked, and come up with the solution)





 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic