A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner
-1
votes
1answer
61 views
Best way to build a hierarchy CLI menu?
I want to build a command line interface with menus and sub-menus and eventually the leafs of the tree should be operations like..
bank management -> account management -> add acount (insert account ...
0
votes
2answers
98 views
What is a good technique to prevent unauthenticated users from accessing controller methods?
I have an event(s) controller:
class Event extends CI_Controller{
public function index(){
}
public function foo(){
}
//Shouldn't be able to use this method unless logged in
...
3
votes
3answers
127 views
What is a static method compared to instance/class/private/public methods?
I'm learning programming in Objective-C and I can't understand what a static method is. I know what class/instance/private/public methods are. Can someone explain what it is using an example and ...
6
votes
3answers
227 views
What is the meaning of “inversion” in `Dependency Inversion Design Principle
I'm reading Design patterns. I know what this principle do. high-level and low-level classes are depend on abstractions. But why we say this inversion?
0
votes
0answers
34 views
How can I access my Handler/runnable class from all my other classes in Android?
I am trying to create a class which allows me to do something every 5 seconds and I want to be able to start and stop this from running from any of the other classes. Here is my Timer class:
public ...
1
vote
1answer
101 views
Is it bad practise to create instances from a SQL-query?
I'm researching ways to create a OO-model/repository-layer using PHP's PDO. My idea was to create model classes that represent a domain object and a repository class for each model that has the ...
1
vote
2answers
181 views
How do objects fit into modern C++ (stl, policy-classes, functional) style?
I'm a bit confused so the question is a bit confusing. TL;dr: how to mix STL and OOP?
From the comment to Best overview to modern C++ paradigms? and ...
2
votes
1answer
78 views
What does the “4” in LCOM4 mean?
I know that methods in a class should have high cohesion which roughly translates to having all the methods use all the instance variables directly or indirectly. I know that LCOM4 (Lack of ...
1
vote
2answers
73 views
Exposing a Disposing event
I'm implementing a .NET class which implements IDisposable. After being disposed, the object's state is invalid and so nobody should be accessing it, of course.
There are some situations where two ...
0
votes
0answers
24 views
Not able to get a Database instance inside a Model class [migrated]
Does a class' __construct() method need to be public, in order to call a static method of this class inside of another class?
I'm trying to get a Database instance inside my Model class (MVC app), by ...
-1
votes
2answers
119 views
A class with extra field
Let's say I have an animal class...with fields of name, height and weight.
I want to create a bird class which is an animal, but it has also, say, wing size.
How can I do that?
My general idea is ...
2
votes
2answers
174 views
Programming style in Perl
I work in Java so basically I use OOP paradigm during coding.
I am about to start working in Perl and I was wondering what is the paradigm that Perl developers follow.
In wiki it mentions that it ...
10
votes
6answers
469 views
What changes are too big to be made easy by proper design?
This is a rather vague question, but it's something I've never felt has been answered in a satisfactory way when reading about proper design.
Generally, when learning about Object Oriented ...
2
votes
1answer
146 views
OOP when using a GUI Designer
I usually do database and web development but at the moment I'm learning desktop development with Mono and Gtk# using using the MonoDevelop IDE. I'm also using the Stetic GUI Designer inside ...
4
votes
2answers
221 views
Why Java does not support private/protected inheritance like C++? [closed]
While inheriting a class in C++, user can specify the access specifier like,
class Base
{
public int mem1;
protected in mem2;
};
class Derived1 : **private** Base
{
// mem1 will be ...
3
votes
1answer
113 views
Better OOP in Javascript - multiple methods or methods with options?
Let's say I have an object like this:
function Foo() {
this.parser = new DataParser();
};
Within Foo I have a method that does something like this:
Foo.prototype.getResponse = function(message, ...
3
votes
2answers
144 views
OOP - Separate Manager class
I have started using OOP in PHP recently. For every model, I create two classes. One class for read operations and another Manager class for all the create / update / delete operations. For example,
...
4
votes
5answers
459 views
How often is Inheritance used?
I admit that I am a junior developer, and so far I've only built simple web applications in ASP.NET MVC. But I've never had to use the inheritance aspect of Object Oriented Programming in my own ...
3
votes
2answers
206 views
Object-Oriented Programming: Why “Oriented”?
I am most of the way through my games programming degree. This is not a computer science degree, so a lot of the theory is eschewed in favour of practical portfolio building and what I see as JIT ...
1
vote
3answers
203 views
What is the difference between polymorphism and factory method? [closed]
Can I say that polymorphism is same as factory method?
EDIT: So basically I can say that a factory method is used to determine at run time which object is required whereas polymorphism already knows ...
-2
votes
1answer
103 views
Javascript Tabletop RPG Character Generator [closed]
What I would like to do, as an exercise, is make a character builder for some sort of tabletop roleplaying game - probably something simple and d20-based like Basic Fantasy or Castles & Crusades.
...
0
votes
1answer
86 views
How to design member access for an Article-type class?
I am doing a final project in a C++ class writing a very simple usenet-like client/server. I figure that since it's usenet-like I'll have a NewsGroup class and an Article class, I'm now working on my ...
6
votes
5answers
291 views
When to use DI and when to create yourself in Java
I've a decent amount of OOP with various languages but am pretty new to Java.
I'm reading through a lot of tutorials where large numbers of objects are created within the code of a class, and I'm ...
0
votes
1answer
228 views
Is object-oriented conceptual thinking something you build with experience? [closed]
I know that the answer is pretty clear because you get better on everything with time and experience. But I'll tell you where I'm coming from:
A couple of months ago I decided to learn iOS ...
5
votes
4answers
258 views
Umbrella term for classes that all serve another class
I'm looking for an umbrella term for classes which are separated from a main class in order to achieve necessary encapsulation and keep main class reasonably sized.
E.g. each blog post is an ...
8
votes
3answers
209 views
Is a single object to be preferred over multiple variables?
It was quite hard to put what I meant into a title, but it's easy to put into code.
C++
Is this
int offset_x = 10;
int offset_y = 40;
...
element.move(offset_x, offset_y);
To be preferred over ...
4
votes
2answers
353 views
Which of these OOP examples demonstrate proper OOP concepts?
I'm still trying to wrap my head around OOP. All of the following examples work, of course, but is there one (or possibly another) that best exemplifies OOP concepts?
/**
* For the following ...
-3
votes
1answer
88 views
What are some key factor when designing GUI? [closed]
What could be considered some key factor on GUI design??
Should it have loot of colors?
how many data should the user see on each screen?
Is there some sort of guide for GUI design?
1
vote
2answers
103 views
Why sequential cohesion for operations in a method is not a good idea?
I read from the seminal Code Complete book that method statements that require to be executed in order passing parameter from one to the next is a code smell and is an example of a sequential ...
2
votes
1answer
121 views
Understanding high cohesion principle for methods in object oriented design
I know the idea of strong cohesion applies to methods as much it applies to classes. Just to be clear when I say strong cohesion of a method I mean a method which does only one task and does it well. ...
1
vote
1answer
103 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 ...
4
votes
3answers
162 views
Which of these OOP examples demonstrate proper OOP concepts?
I'm still trying to wrap my head around OOP. All of the following examples work, of course, but is there one (or possibly another) that best exemplifies OOP concepts?
/**
* For the following ...
7
votes
3answers
95 views
Rules about the concreteness of method parameter types, return types and property types
Some time ago I read a kind of "rule of thumb" about the concreteness of method parameter types, return types and property types, but I just do not remember it.
It said something about keep your ...
4
votes
3answers
208 views
How should my web application handle common errors such as incorrect password, session timeout, etc.?
How should my web application handle common errors such as incorrect password, session timeout, etc.?
I have a class called Hotmail that contains various method such as login, logout etc.
To ...
4
votes
2answers
208 views
Preventing Liskov Substitution violation
I am reimplementing some component and noticed that the original version has a Liskov Substitution violation. It's not all that critical, though I'd like to get rid of it in the new implementation . ...
20
votes
6answers
842 views
How to avoid giant glue methods?
In my current job, I've been tasked with cleaning up old code a few times. Often the code is a labyrinth and the data behind it is even more tangled. I find myself combing out things into nice, ...
1
vote
1answer
96 views
What is a general solution to allow the client to choose the concrete instance of a method output?
What is the general solutions to allow the client to choose the concrete instance of a method output?
For example, in the Lucene API the search method receives and modifies the collector input ...
3
votes
7answers
231 views
Naming guard clauses that throw exceptions
I have a function evaluate() that parses a String for some variables and replaces them with their corresponding value:
public String evaluate() {
String result = templateText;
for ...
0
votes
1answer
87 views
How can I cleanly separate first open tutorial code from my regular display code under OOP?
I have a MVC architecture, and I have the basic views completed. I now need to add the first user tutorial mode into the project. I don't want to add checks for first user state in all the views that ...
0
votes
1answer
159 views
How can my code structure be improved? [closed]
I am looking for advice on the neatest way to structure my code.
class Password
{
private string cipher;
Password(string cipher)
{
this.cipher = cipher;
}
public string ...
7
votes
2answers
138 views
How would I combine 'Command' and 'Composite' to simulate a time delay?
As a learning exercise (I am not in school - just an old guy trying to learn something new), I am trying to write a logic gate simulation that incorporates propagation delay. The user should also be ...
4
votes
2answers
243 views
PHP OOP: Should every object contain all the data?
I'm trying to learn PHP OOP "properly", and I was wondering, should the constructor grab all the information in the database and store it in the object?
To use an example I'm trying to create using ...
5
votes
2answers
128 views
Domain Services as facades
I read .NET Domain-Driven Design with C#: Problem - Design - Solution and I noticed that the author created a domain service for each aggregate root.
However, the domain services were only facades to ...
0
votes
1answer
102 views
Code reuse via inheritance [duplicate]
I have a set of classes that are all dealing with some related tasks. These tasks do have different inputs and outputs. This causes it to become impossible to have the tasks done via shared code ...
1
vote
1answer
97 views
OOP question for product catalog
I have a question bugging me for some days. I made a webshop for a good friend of me. The problem is I have an OOP class question.
People can buy some clothing in the shop. The problem arise how to ...
7
votes
1answer
382 views
What API design for storing generic data in a more specific format?
for In the project I am working on we send messages about widgets over message queues, serializing them onto the queues as XML. The XML schema contains tags for properties that are common to all types ...
0
votes
2answers
382 views
Simple real-world PHP OOP example?
I'm trying to learn PHP OOP, but when I've followed tutorials, all the examples seem to involve things like:
class Human {
$_sex;
public function setSex($sex) {
$this->_sex = ...
0
votes
3answers
123 views
Changing behaviour of abstract class without modifying subclasses
I am facing a problem with changing behaviour of a library (thus cannot or don't want to change its internals because of future updates, etc.).
In this library there is an abstract class which shares ...
5
votes
2answers
161 views
How does strengthening of pre conditions and weakening of post conditions violate Liskov Substitution principle?
I read that Liskov substitution principle is violated if :
Pre conditions are strengthened .
Post conditions are eased out.
But I don't get fully yet how these two points would violate Liskov ...
2
votes
2answers
112 views
Identifying Domain Services & Application Services when doing DDD
-I'm trying to figure out how to identify Application Services in my application. I think I can identify a Domain service by 2 things:
It acts as a facade to the repository.
It holds business logic ...