Relative Content

Tag Archive for class-design

How to properly design classes for a big project?

If we need to represent classes in a class diagram for a big project that is not completely designed yet, and the classes have to be actual tables in a database, how would we predict and design the classes?

How to represent association in programs [closed]

It’s difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago. Could someone help me in implementing association in […]

Object Oriented Programming: getters/setters or logical names

I’m currently thinking about an interface to a class I’m writing. This class contains styles for a character, for example whether the character is bold, italic, underlined, etc. I’ve been debating with myself for two days whether I should use getters/setters or logical names for the methods which change the values to these styles. While I tend to prefer logical names, it does mean writing code that is not as efficient and not as logical. Let me give you an example.

Data classes: getters and setters or different method design

I’ve been trying to design an interface for a data class I’m writing. This class stores styles for characters, for example whether the character is bold, italic or underlined. But also the font-size and the font-family. So it has different types of member variables. The easiest way to implement this would be to add getters and setters for every member variable, but this just feels wrong to me. It feels way more logical (and more OOP) to call style.format(BOLD, true) instead of style.setBold(true). So to use logical methods instead of getters/setters.

Is it bad practice to pass instances through several layers?

In my program design, I often come to the point where I have to pass object instances through several classes. For example, if I have a controller that loads an audio file, and then passes it to a player, and the player passes it to the playerRunnable, which passes it again somewhere else etc. It looks kind of bad, but I don´t know how to avoid it. Or is it OK to do this?

Isn’t class scope purely for organization? [duplicate]

This question already has answers here: Why do we need private variables? (15 answers) Closed 11 years ago. Isn’t scope just a way to organize classes, preventing outside code from accessing certain things you don’t want accessed? More specifically, is there any functional gain to having public, protected, or private-scoped methods? Is there any advantage […]