Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Difference between Singleton and SRP(Single Responsibility Principle)Can you explain the difference in plain language with examples?
If an object is a person, singleton means that there is only one person of a given type in the world. You cannot find there are another person of the same type in the world.
Single Responsibility Principle (SRP) means that a person only focus on and can only do one thing. So even if you are the only the person of a given type in the world (i.e. singleton) , if you can do many things that are not related to each other , you are not SRP enough.
So you can see they are different concepts which do not related to each other. Singleton is about the quantity of certain kind of object. SRP is about what things can an object do.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Take MyClass and it has a lot of methods. Some are there for a particular role, and other methods for another.
Is there any way to group them "per role" and be able to use that information in code in figuring out the methods group and using it?
The closest I can think of are protocols, see https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithProtocols/WorkingwithProtocols.html
With this method:
- (BOOL)conformsToProtocol:(Protocol *)aProtocol
you can check if an object implements a particular protocol.
"Take MyClass and it has a lot of methods. Some are there for a particular role, and other methods for another".
The question is the answer, your class is doing way too much. A class for each role sounds like a good start, and perhaps one to delegate from.
Can't say how you should break the class up from here, but that you should is inarguable.
If your class has a lot of methods, split it into smaller classes with fewer methods.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
In chubby the process of each log that write to db is one instance of the paxos process, and this instance may have many proposers, so it will have a master selected process.
why it has many proposers?
Having a single leader (aka a "Distinguished Proposer") is an optimization for Paxos. The whole point of Paxos is to decide a value when there are multiple proposers proposing different things.
The whole point of having multiple proposers is in case the "Distinguished Proposer" fails; something has to pick up that new role. Paxos, when it decides a value, implicitly decides between proposers.
As in your other question, I suggest looking at the other Paxos questions, perhaps read Paxos Made Simple.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
When companies ask you to do OO design related questions in the interview, what do they really expect? Do they expect you to briefly tell them the algorithm and some pseudocode or do they actually expect you to write the entire structure of the code?
For example question like : Design a musical jukebox. Do I start off telling what classes I will make with some pseudocode or what?
Design does not mean implementation.
Design means:
what all classes you will have
The methods(functionality) your classes will provide
What will be the relation between classes you have
What will be the Lifetimes of objects of your classed
Having said a design is not something which gets done in a mere 15-20mins of an interview.It's all blood and sweat and it needs lot of time and consideration albeit discussions to arrive at a good design.
In a interview the Questioner usually want to know if you can think in the right direction atleast.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I found this abbreviation in many projects it is a folder referring to database models in an active record context
but What does it mean exactly ?
VO normally stands for Value Object.
In Domain Driven Development (DDD), value objects represent one or more pieces of information, but do not contain an identity. For instance, an Address object containing street address, city, state, and zip would be considered a value object.
This site can provide more info: http://devlicio.us/blogs/casey/archive/2009/02/13/ddd-entities-and-value-objects.aspx
VO stands for Value Object. The difference from normal objects is that value objects' only purpose is to store values in a convenient way. In short that means that a value object just contains a bunch of properties and no methods.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have a class called 'Inventory' that has two subclasses, 'Drink' and 'Condiment'. They are a part of a software system being developed for use in a hot drinks vending machine. Note that this isn't really going to be implemented, rather it is a piece of coursework for my Software Engineering class. Anyway, I'm having trouble deciding what stereotype to apply to 'Inventory', as I can see it having aspects of both a control class (managing the drinks and condiments during a transaction), and of an entity class (noting the quantities of each item in its subclasses, but it also is the sole manager of the water water levels, as hot water is common to all drinks dispenses from this machine).
I'm basically looking for some guidance on how to classify this class. Thanks a lot.
You might consider that since you are unsure how to classify it, perhaps you could design separate control and entity classes. First rule of software engineering: if the design feels wrong then it probably is.
Come to think of it, the zeroth rule is: know when to ignore the other rules, especially the ones about stereotypes and design patterns.
I vote for entity class -- Having inventory is not the same as controlling inventory.