Click here to Skip to main content
Click here to Skip to main content

To do or to doer.go()?

, 27 Jul 2012
Rate this:
Please Sign up or sign in to vote.
One of the most important things about Java is their "as is" approach to "everything is an object" concept.
For the last year I've been mostly using Java. After having a lot of experience with C#, its events, delegates, lambdas and generics, Java feels pretty weird. One of the most important things about Java is their "as is" approach to "everything is an object" concept. If you want something, it definitely should be an object. If you want an object, you either have to have a factory (to build composites) or build a new class.

It appears that the modern object-oriented approach to software design should be declared like this:
  1. You build a number of small silly classes. Every class should incarnate the only concept.
  2. You create objects of your classes and wire them together, depending on logic you want. The idea is, you're normally payed for implementing complicated concepts, so you have to describe the problem in terms of your primitive concepts. At this point you have an object graph (or network) where nodes are simple processors aimed to solve simple problems. This network has input and output nodes.
  3. You then take your input data (mouse movements, HTTP-requests, whatever) and pass it to the input node(s) of your network. Then you read network's output and send it back (UI animations, HTTP-reponses, ...)
This approach is encouraged by GoFP of EAA and others. There's a number of IoC containers to help with wiring objects together, there are mock object frameworks aimed to help with testing individual classes/objects and their impact to the dependencies.

But, frankly, after trying to write code accepting all these values, I have a feeling that something's wrong:
  • I build classes like PersonNameFormatter which have the only method - format(String firstName, String lastName).
  • I build a plenty of small classes, which are sweet as long as you see them individually.
  • I think in terms of "I want a doer" instead of "I need to do".
  • Looks like I'm not that far from using the concept of "evaluators" everywhere: IfEvaluator, ForEachEvaluator, etc.
  • When I try to understand how the whole application works, the only idea that comes to mind is: "well, it works somehow, there are sweet small classes, and then objects are created and wired, it should just work".
And even more frankly, I think that writing terrible procedural code with 500 LoC procedures should not be considered that bad.
Here's an interesting reading related with the topic - http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

loki2302
Software Developer (Senior)
Russian Federation Russian Federation
No Biography provided
Follow on   Twitter

Comments and Discussions

 
QuestionDescription PinmemberKenneth Haugland27-Jul-12 5:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 27 Jul 2012
Article Copyright 2012 by loki2302
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid