Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 109689

A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

0 votes

Is it a good idea to have logic in the equals method that doesn't do exact matching?

As others have mentioned, the exact semantics of object equality are a part of the business domain's definition. In this case, I don't think it's reasonable to have a "general" object like Address (co …
Alexander's user avatar
  • 4,954
2 votes

Where to put a method which uses only public interface of its class?

I would most certainly go with the first option. The second option is nonsensical, the whole point of a class method is that it's not dependent on any particular instance of the class. A method that …
Alexander's user avatar
  • 4,954
5 votes

What is a proper use of downcasting?

There is a trade-off between static and dynamically typed languages. Static typing gives the compiler a lot of information to be able to make rather strong guarantees about the safety of (parts of) pr …
Alexander's user avatar
  • 4,954
4 votes

Accessing properties from embedded objects as attributes of container class

This is one way of mitigating violations of law of Demeter. I would provide caution on two things: When you assign the subattributes of A and B to attributes, you're taking a snapshot in time. Futher …
Alexander's user avatar
  • 4,954
0 votes

Is "Parent x=new Child();" instead of "Child x=new Child();" a bad practice if we can use th...

I would suggest always returning or storing variables as the most specific type, but accepting parameters as the broadest types. E.g. <K, V> LinkedHashMap<K, V> keyValuePairsToMap(List<K> keys, List …
Alexander's user avatar
  • 4,954
1 vote

In OOP, isn't the 'protected' keyword required?

You mentioned Swift explicitly, so I'll answer about why Swift doesn't have protected. Unlike many other languages, Swift lets you write "extensions" to other types (classes, structs, enums and proto …
Alexander's user avatar
  • 4,954
0 votes

Is it a bad idea have make a class method that is passed class variables?

This is a classic "C with classes" approach to C++. In reality, this isn't what any seasoned C++ programmer would write. For one, using raw C arrays is pretty much universally discouraged, unless you' …
Alexander's user avatar
  • 4,954
0 votes
2 answers
4k views

Unit testing private methods

preface: I know this topic has been asked about a lot on here in the past. Hopefully I will make it clear that I've read a fair amount of the questions/answers on the topic, and other literature, too. …
Alexander's user avatar
  • 4,954