information-hiding

Abstraction VS Information Hiding VS Encapsulation

Can you tell me what is difference between ABSTRACTION and INFORMATION HIDING in software development? I am confused abstraction hides detail implementation and information hiding abstracts whole details of something. updated: I found good answer for these three concepts. From here: http://www.itmweb.com/essay550.htm Abstraction: ...

Why should the "PIMPL" idiom be used?

Backgrounder: The PIMPL Idiom is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of. This hides internal implementation details and data from the user of the library. When implementing the this idiom why would you place the public...

Why are Python's 'private' methods not actually private?

Python gives us the ability to create 'private' methods and variables within a class by prepending double underscores to the name, like so: *__myPrivateMethod()*. How, then, can one explain this >>> class MyClass: ... def myPublicMethod(self): ... print 'public method' ... def __myPrivateMethod(self): ... ...

What are nested functions? What are they for?

I've never used nested functions, but have seen references to them in several languages (as well as nested classes, which I assume are related). What is a nested function? Why?!? What can you do with a nested function that you cannot do any other way? What can you do with a nested function this is difficult or inelegant without nested ...

A brilliant example of effective encapsulation through information hiding?

"Abstraction and encapsulation are complementary concepts: abstraction focuses on the observable behavior of an object... encapsulation focuses upon the implementation that gives rise to this behavior... encapsulation is most often achieved through information hiding, which is the process of hiding all of the secrets of object that do no...

Obfuscation or hiding of server to client state updates

I'm not actually writing this software myself, but it occurred to me that I have no idea how to solve the problem. As the best way to explain the problem, I'll describe a specific scenario from a hypothetical multi-player first-person shooter game... Player A is hiding in some bushes facing west Player B is sneaking up on player A from...

Is it better to pass an *interface* or an *object* as a parameter to a function?

I'm trying to convince a colleague that a function should take an interface as a parameter, and not the object itself. I think small objects can be fine to pass across, but for large ones I would give them an interface and just pass the i/f over, not the whole thing. Note that there will only ever be one of these large classes - the i/f...

How much information hiding is necessary when doing code refactoring?

How much information hiding is necessary? I have boilerplate code before I delete a record, it looks like this: public override void OrderProcessing_Delete(Dictionary<string, object> pkColumns) { var c = Connect(); using (var cmd = new NpgsqlCommand("SELECT COUNT(*) FROM orders WHERE order_id = :_order_id", c)...

Use of Frames in Delphi for GUI information hiding

Hi, I have been learning Delphi for the last 3 years, on a hobby/occupational level. I am happy to say that I have now progressed to the point that I can look back on my early code with horror and embarrassment. So I am now going through some of my early apps and rewriting/ refactoring them. One of the bad habits I am trying to get away...

How can you hide information inside a jpg or gif photo?

How can I write some information inside a photo file like jpg or gif without destroying the image? and of course without showing it on the photo since the whole idea is to send information in the file of photo undetected by anyone (to provide security/privacy to some extent)! ...

Hiding Complexity by Building Concise Libraries

I'm developing a product with a bunch of interlocking pieces (server, client, libraries, etc) and one of the pieces is a tiny library that users will link into their own client-side code (something kind of like the Flickr API or the Google Maps API). Once they've included that library, all of the interlocking bits magically hook themselv...

Information Hiding vs. Hidden Dependencies

Dear StackOverflow, What are some common best practices in procedure (or function, module, etc.) design for balancing the desire for information hiding and an appropriate level of abstraction in the procedure's interface with the problems inherent in introducing hidding dependencies? To be more concrete, suppose I code a procedure call...

Best way to store data between program runs in java?

I was wondering if there was any way other placing the information that is genereated by the program between runs of the program? I already know that you can use a text file and store the information that way but I was wondering is there a better way? Also is there any way to do it so as to keep the information secure? from the end user ...

How does the design of JavaBeans square with information hiding?

Two semesters ago, I had a professor who said: Some of you have been told to always include setter and getter methods for all private instance variables. I say that this breaks information hiding, and often results in systems where invariants cannot be enforced. Now, that sounds right to me. But isn't including those kinds of sett...

how does information hiding helps in modularization?

How does information hiding decouples the modules that compromise a system? ...

Where do you put unit tests for private methods?

Where do you put unit tests for private functions in C# classes? An article in Wikipedia suggests: Putting tests in the same class as the members they're testing Using partial classes Personally, neither of these methods seem appropriate, and I much prefer to have unit tests located in a separate project altogether. Any thoughts on...

[NHibernate and ASP.NET MVC] How can I implement a robust session-per-request pattern in my project, while focusing on information hiding?

I'm currently building an ASP.NET MVC project, with NHibernate as its persistance layer. For now, some functionnalities have been implemented, but only use local NHibernate sessions: each method that accessed the database (read or write) needs to instanciate its own NHibernate session, with the "using()" directive. The problem is that ...

What's the most appropriate way to expose lists inside a class?

Imagine the following model: A Table has many Rows A Row has many Cells What would be the preferable interface to deal with these classes in a "object oriented way"? 1 - Provide access to the properties rows / cells (Not necessarily exposing the underlying data structures, but creating for example a class RowCollection...) my_table...

Dependency Injection, Unit Testing, and Information Hiding

Suppose you have a class Foo with private member of type Bar. You don't want users to know that Foo's implementation contains a Bar and you don't want users to be able to create their own Bar and pass it through Foo's constructor, any other method, or a configuration file. Edit: Bar is also problematic in that it accesses resources ...

Creating internal and external interfaces for a class / information hiding

For some classes of a static C++ library I want to offer different interfaces for the user of the library and for the library itself. An example: class Algorithm { public: // method for the user of the library void compute(const Data& data, Result& result) const; // method that I use only from other classes of the lib...