Tagged Questions
1
vote
3answers
174 views
Keeping track of all objects of a class
I'm new to object-oriented programming, and I keep running into this issue. (I'm programming in Java) I've been a bit reluctant to ask about this, since it seems like such a basic issue, but I can't ...
18
votes
4answers
713 views
How do purely functional languages handle modularity?
I come from an object oriented background where I've learned that classes are or at least can be used to make a layer of abstraction that allows for easy recycling of code which can then either be ...
0
votes
1answer
187 views
Teaching `class`es and objects in C++ to university students
To learn classes and objects at my university, students are required to develop a simple game (nine-mens morris or something similar) using Java. Java is used because of its libraries and tool ...
1
vote
1answer
137 views
Analogy of a class being a cookie cutter and objects being cookies
I came across the analogy of the class being a cookie cutter and the cookies being objects while reading Code Complete. I fail to see why this analogy was drawn.How is it related to the concept of ...
1
vote
1answer
144 views
Is there a good design pattern for this messaging class?
Is there a good design pattern for this?
I want to create a messaging class.
The class will be passed:
the type of message (eg. signup, signup confirmation, password reminder etc)
the client's id
...
18
votes
5answers
1k views
How do I prove or disprove “god” objects are wrong?
Problem Summary:
Long story short, I inherited a code base and an development team I am not allowed to replace and the use of God Objects is a big issue. Going forward, I want to have us re-factor ...
16
votes
5answers
933 views
Why am I seeing so many instantiable classes without state?
I'm seeing a lot of instantiable classes in the C++ and Java world that don't have any state.
I really can't figure out why people do that, they could just use a namespace with free functions in C++, ...
-3
votes
8answers
1k views
Why do we need to separate classes which have different functionality? [closed]
Why do we need to separate classes which have different functionality? For example, why should we separate a car class from a paint class. What would be the OOD concept behind this? Is there anything ...
1
vote
1answer
89 views
How to represent association in programs [closed]
Could someone help me in implementing association in cpp. I am trying to implement a dice game where I have two classes a diegame and a dice.
37
votes
11answers
4k views
Why is it good to split a program into multiple classes?
I'm still a student in high school (entering 10th grade), and I have yet to take an actual computer course in school. Everything I've done so far is through books. Those books have taught me concepts ...
-1
votes
1answer
365 views
What is the difference between class level attributes, Class constants and singleton methods?
What the difference given they all exist 'once per class'.
When should I use one over another, i.e. for what purpose?
I use Ruby.
0
votes
2answers
544 views
Is it best practice to always capitalize class file names in PHP, and other languages?
I ask because I've seen a couple of OO PHP tutorials which do not adhere to this, but to me it just makes sense. It makes it easy to instantly see if a file is a class or not, if non-class files all ...
11
votes
7answers
3k views
What are the roles of singletons, abstract classes and interfaces?
I am studying OOP in C++ and, even though I am aware of the definitions of these 3 concepts, I cannot really realize when or how to use it.
Let's use this class for the example:
class Person{
...
1
vote
3answers
260 views
Any language where every class instance is a class too?
Taking inspiration from Javascript prototypes, I had the idea of a language where every instance can be used as a class.
Before I potentially reinvent the wheel, I would like to ask if there is a ...
2
votes
2answers
108 views
Would be semantically correct to make a “Login” constructor in an api class?
Since the methods of the class will only work if the user is logged in, is it right or is there some problem that might make my code slow/inneficient?
4
votes
3answers
641 views
Is this the correct approach to an OOP design structure in php?
I'm converting a procedural based site to an OOP design to allow more easily manageable code in the future and so far have created the following structure:
/classes
/templates
index.php
With these ...
2
votes
3answers
260 views
Want to know performance issues of Class types & access modifiers
Someone suggested me to mark classes as SEALED that are not being inherited anywhere. I was using default style and was not concerned with the type of class. At present I don't have a benchmark tool ...
11
votes
4answers
509 views
Nested Classes: A useful tool or an encapsulation violation?
So I'm still on the fence as to whether or not I should be using these or not.
I feel its an extreme violation of encapsulation, however I find that I am able to achieve some degree of encapsulation ...
