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