encapsulation

PHP - Frameworks, ORM, Encapsulation.

Programming languages/environments aside, are there many developers who are using a framework in PHP, ORM and still abide by encapsulation for the DAL/BLL? I'm managing a team of a few developers and am finding that most of the frameworks require me to do daily code inspection because my developers are using the built in ORM. Right now...

JavaScript Encapsulation / JQuery

I am trying to figure out how to keep my page variables in my application from being defined globally. I've come up with a few methods but am wondering if there is a general standard approach people use. I've got my plugin design pattern down using this approach: http://www.virgentech.com/blog/2009/10/building-object-oriented-jquery-plu...

basics of c++ encapsulation

I have a task to create class Encapsulation, with fields in available encapsulation sections. Then I must create an application showing all allowed and forbidden methods of fields access. What are the encapsulations sections in c++ ? And what methods apart from object.field or *object->field are there anyway ? ...

How might a C# programmer approach writing a solution in javascript?

UPDATE: Perhaps this wasn't clear from my original post, but I'm mainly interested in knowing a best practice for how to structure javascript code while building a solution, not simply learning how to use APIs (though that is certainly important). I need to add functionality to a web site and our team has decided to approach the solutio...

A Question on Encapsulation.

Hi, I know that encapsulation is binding the members and its behavior in one single entity. And it has made me think that the members have to be private. Does this mean if a class having public members is not following 100% Encapsulation rule? Thanks ...

Read only observable collection

I have my class that has an internal observable collection. I want to pass the data in this to a user of the class via a function. I don't want them to be able to change the objects inside of the observable collection or the collection itself. What is the best way to do this performance and ease of use wise? ...

Idiomatic ruby for temporary variables within a method

Within a method, I am using i and j as temporary variables while calculating other variables. What is an idiomatic way of getting rid of i and j once they are no longer needed? Should I use blocks for this purpose? i = positions.first while nucleotide_at_position(i-1) == nucleotide_at_position(i) raise "Assumption violated" if i == 1 ...

What are the benefits of using properties internally?

Encapsulation is obviously helpful and essential when accessing members from outside the class, but when referring to class variables internally, is it better to call their private members, or use their getters? If your getter simply returns the variable, is there any performance difference? ...

How to encapsulate a third party complex object structure?

Motivation Currently I'm using the java parser japa to create an abstract syntax tree (AST) of a java file. With this AST I'm doing some code generation (e.g.: if there's an annotation on a method, create some other source files, ...) Problem When my code generation becomes more complex, I've to dive deeper into the structure of the A...

Break a class in twain, or impose an interface for restricted access?

What's the best way of partitioning a class when its functionality needs to be externally accessed in different ways by different classes? Hopefully the following example will make the question clear :) I have a Java class which accesses a single location in a directory allowing external classes to perform read/write operations to it. ...

method without access modifier

Ok this is bugging me.. I know I've read it somewhere and google isn't helping. What is the accessibility level of a method that does not specify an access modifier? void Foo() { //code } I want to say internal but I'm not 100% sure. ...

Is it proper to get and especially set Perl module's global variables directly?

I was wondering what the best practice in Perl is regarding getting - or, more importantly, setting - a global variable of some module by directly accessing $Module::varName in case the module didn't provide getter/setter method for it. The reason it smells bad to me is the fact that it sort of circumvents encapsulation. Just because I ...

Exception throws: encapsulate them or not?

Hi there. Once I read an MSDN article that encouraged the following programming paradigm (its not 100% true... see edit): public class MyClass { public void Method1() { NewCustomException(); } public void Method2() { NewCustomException(); } void NewCustomException() { throw ne...

Prefer extension methods for encapsulation and reusability?

edit4: wikified, since this seems to have morphed more into a discussion than a specific question. In C++ programming, it's generally considered good practice to "prefer non-member non-friend functions" instead of instance methods. This has been recommended by Scott Meyers in this classic Dr. Dobbs article, and repeated by Herb Sutter a...

Properties vs. Fields: Need help grasping the uses of Properties over Fields.

First off, I have read through a list of postings on this topic and I don't feel I have grasped properties because of what I had come to understand about encapsulation and field modifiers (private, public..ect). One of the main aspects of C# that I have come to learn is the importance of data protection within your code by the use of en...

PHP's _get & _set or unique get and set functions for each variable?

PHP has _get and _set functions built in. Is it better to write my own get and set functions for each variable or use the built in functions with a ton of if else if? What are the pros and cons of each method? ...

WPF element that dynamically creates (encapsulated) children at runtime

I want to create a WPF element that, at runtime, is in full control of its child elements -- adding and removing child UI when its properties change. Something a bit like what ItemsControl does when you modify its ItemsSource property, though in my case there'll only be one child. This will be a view container for MVVM -- when you give ...

In C++, does adding a friend to a class change its memory layout ?

Also, does it matter where in the class you declare the friend ? Does it matter if you add a friend class or a friend function ? ...

Abstracting away from data structure implementation details in Clojure

I am developing a complex data structure in Clojure with multiple sub-structures. I know that I will want to extend this structure over time, and may at times want to change the internal structure without breaking different users of the data structure (for example I may want to change a vector into a hashmap, add some kind of indexing ...

private object pointer vs object value, and returning object internals

Related to: http://stackoverflow.com/questions/2625719/c-private-pointer-leaking According to Effective C++ (Item 28), "avoid returning handles (references, pointers, or iterators) to object internals. It increases encapsulation, helps const member functions act const, and minimizes the creation of dangling handles." Returning objects ...