Relative Content

Tag Archive for object-oriented

Do unit tests sometimes break encapsulation? [duplicate]

This question already has answers here: Should I avoid private methods if I perform TDD? (14 answers) Closed 10 years ago. I very often hear the following: “If you want to test private methods, you’d better put that in another class and expose it.” While sometimes that’s the case and we have a hiding concept […]

How can I explain object-oriented programming to someone who’s only coded in Fortran 77?

My mother did her college thesis in Fortran, and now (over a decade later) needs to learn c++ for fluids simulations. She is able to understand all of the procedural programming, but no matter how hard I try to explain objects to her, it doesn’t stick. (I do a lot of work with Java, so I know how objects work) I think I might be explaining it in too high-level ways, so it isn’t really making sense to someone who’s never worked with them at all and grew up in the age of purely procedural programming.

Ways to ensure unique instances of a class?

Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. I’m looking for different ways to ensure that each instance of a given class is a uniquely identifiable instance. For example, I have a […]

How get and set accessors work

The standard method of implementing get and set accessors in C# and VB.NET is to use a public property to set and retrieve the value of a corresponding private variable. Am I right in saying that this has no effect of different instances of a variable? By this I mean, if there are different instantiations of an object, then those instances and their properties are completely independent right? So I think my understanding is correct that setting a private variable is just a construct to be able to implement the get and set pattern? Never been 100% sure about this.

Using dot to Access Object Attribute and Proper abstraction

I have been programming in python and Java for quite a number of years and one thing I find myself doing is using the setters and getters from Java in Python but a number of blogs seem to think using the dot notation for access is the pythonic way.