Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's hard to critique your design without a better idea of what you are trying to do. I know that it involves balls and boards, but other than that, I have no idea.</p> <p>Try to avoid singletons as much as possible. Yes, I know that the GoF book lists it, and I know that it is a common pattern, but in my experience it ends up becoming an anti-pattern. </p> <p>You mention that IBall and IBoard don't have any logic about how they interact. Does that imply that they don't have any methods? Are their methods just getters and setters for their private data? If IBall and IBoard are just structs (or their equivalent), then they don't need to be interfaces. Could you flesh out your description to talk about the kinds of messages that you can send to an IBall and to an IBoard?</p> <blockquote> <p>2) Should (in general) Logic be separate from the Objects / data?</p> </blockquote> <p>Sometimes. If you have plain old data, then separating the logic from the plain data is fine. Of course, then you're not doing OOP anymore - you are writing procedural code. I think you're struggling with the desire to not hard-code any behavior into Ball. Perhaps some other entity should be responsible for deciding how balls interact, but you still have room for Ball to participate in the decision. This is where the strategy pattern (among other patterns) would come into play. Think about how things work in the real world - how would a physical ball and a physical board coordinate their interactions? If they talked to each other, what would they say? See if you can implement that in your code.</p> <p>Finally, a word about design. I think it's good to want to "get the design right." On the other hand, that's the path towards becoming an <a href="http://www.joelonsoftware.com/items/2008/05/01.html" rel="nofollow noreferrer">architecture astronaut</a>. Consider what problems you currently have with your code base.</p> <ul> <li>Is it hard to refactor?</li> <li>Is it hard to add new types of things?</li> <li>Is too much "hard-wired"?</li> </ul> <p>Design doesn't exist in a vacuum - it is informed by the current state of the world. Just look at some of the crazy cell phone concept art that people come up with, and you'll see good examples of bad design. Cell phones are limited by current technology, and designs that ignore the restrictions of the real world are nothing more than dreams. The same is true in software. Pay attention to what the code is telling you it needs, and you'll do fine.</p> <p>The more software you write (and finish), the more experience you will have, and the better your sense of aesthetic will become. Don't let fear of "doing it wrong" stop you from finishing your software. Persevere, make it work, and then see what you learned from the process.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload