Posts Tagged programming

Method Refactoring

[info]bpfurtado has raised an important question concerning some odd practices in software programming. People who code applying the same paradigm to all computer languages, thinking the only difference between programming languages are all about their syntax and grammar. These kind of code generate a lot of bad consequences, like the one I will focus at this post.

Sometimes I see people writing methods like “doX&Y&Z”, reflecting more than one responsability inside a method. Clearly this kind of design isn’t focused on reuse and maintenance, because people who code this way don’t even know such practices, characterized in OO programming. Methods must be cohesive, that is, “a cohesive method is responsible for one and only one well-defined logical task”.

Such a method could be factored into three little private methods, named “doX”, “doY” and “doZ”. To one public method is given the responsability to coordinate the tasks between the three methods. Talking about the former approach, how can you reuse one of the computation inside the “big” method? It’s impossible. So, reuse and maintenability is better achieved in the latter approach.

It occurs that people start programming in a language without knowing the paradigm it applies. So, people need to change their mind to produce better code, otherwise real big projects will continue to suffer the same problems we are tired of hearing nowadays.

Tags:

Interview with Grady Booch

Interesting interview with Grady Booch, an IBM fellow who developed the first drafts of OOP and the Booch Method, which was a precursor to UML. In this interview, he explains why most companies are wrong in doing what they called SOA. Moreover, he says why UML was created and what he does now at IBM. Very nice.

Tags:

Don’t be passionate with your language of choice …

The majority of software developers have a language of choice. Some may chose their preferred language based on the paradigm it applies, others may evaluate if the language is static or dynamic, if it has weak / strong typing, nice and interesting language constructs (like closures, continuations) and other various criteria. My preferred language is Java (up to now, because I’m studying Python, and this language is becoming a good candidate to be my language of choice for a lot of reasons, but these will be part of another post :-)), because it’s a good OO language and it offers good opportunities to apply OOA/D, that is, to construct well-designed, maintainable, robust OO systems.
Therefore a problem can arise: if the developer tries to keep this preference for a specific language / platform in the organization. This can become a passion and every new project the developer is asked to give a opinion the choice will be his/her preferred language, because he/she believes it’s the best language of the world, because he/she got used to the language. If the developer participates in a open-source community and its company decides to chose a proprietary language, the fight with managers is even worse. So, always remember:

  • The language of your choice might not be appropriate to solve a specific problem. You have to evaluate other languages / platforms to achieve the best results. It’s your routine as a software developer. Perhaps other language offers a better cost / benefit than your preferred language (You can solve your problem with fewer lines of code with a different language, for example).
  • You are in a company to achieve results, not to program in Java, .NET, Python or anything else. Always have this in mind. Don’t let your passion hide your opportunities in a company.

Have you ever seen some situations like these on your development team?

Tags: