Showing posts with label oop. Show all posts
Showing posts with label oop. Show all posts

Friday, May 25, 2012

Examples of GoF Design Patterns


I am learning GoF Java Design Patterns and I want to see some real life examples of them. Can you guys point to some good usage of these Design Patterns, preferably in Java's core libraries?

Thursday, May 17, 2012

Is it just me or are interfaces overused?


Ok, I may resort to a tad ranting here, so let me apologize in advance, but I'm really curious if others find this pattern annoying too (and I wonder if it is a justifiable pattern)…

Tuesday, May 15, 2012

Difference between code before and after super()


Look at the sample codes below




@Override
protected void onPause() {
...some code here...
super.onPause();
}

Is it ever okay to have a class as a collection of methods and no properties?


I'm writing a bunch of generic-but-related functions to be used by different objects. I want to group the functions, but am not sure if I should put them in a class or simply a flat library file.

OOP the point of interface



Possible Duplicate:

Interface vs Abstract Class (general OO)




EDIT: I just read the questions and answers to the questions from "possible duplicate" and I feel really sad that someone considers these two questions even similar... but, oh well...

Static methods: are they still bad considering PHP 5.3 late static binding?


If you search on the reasons why static methods are bad the first thing you find it is because you can't override it when you are unit testing.

Wednesday, May 9, 2012

Is it bad to declare an empty class?


In my spare time, I am building a Sudoku solver to try to get the hang of OOP in PHP. A Sudoku puzzle, for those of you who don't know, is in its most common form a 9x9 matrix of numbers from 1 to 9, with 3x3 squares delineated in a tic-tac-toe like pattern. Some numbers are filled in in advance. The goal of the puzzle is to fill in the remaining numbers, so that no row, column or 3x3 square contains the same number more than once.

Friday, May 4, 2012

OOP Design Question - Where/When do you Validate properties?


I have read a few books on OOP DDD/PoEAA/Gang of Four and none of them seem to cover the topic of validation - it seems to be always assumed that data is valid.

Thursday, May 3, 2012

Java-esque OOP in JavaScript and a jQuery fail


I'm working on a project and I'm really trying to write object-oriented JavaScript code. I have just started reading Douglas Crockford's JavaScript: The Good Parts and I'm quickly beginning to realize that writing Java-esque OOP in JavaScript will be a difficult task.

Wednesday, April 25, 2012

Game design in an OO manner


I'm designing a simple game, which uses Java 2D and Newtonian physics. Currently my main "game loop" looks something like:

Getters and Setters are bad OO design?


Getters and Setters are bad



Briefly reading over the above article I find that getters and setters are bad OO design and should be avoided as they go against Encapsulation and Data Hiding. As this is the case how can it be avoided when creating objects and how can one model objects to take this into account.

Monday, April 23, 2012

Using Interfaces in Kohana 3.1.3


I'm trying to build a form wizard in Kohana and am learning a bit as I go. One of the things that I've learn might work best is utilizing a state pattern in my class structure to manage the different steps a user can be in during the form process.

Thursday, April 19, 2012

Benefits of prototypal inheritance over classical?


So I finally stopped dragging my feet all these years and decided to learn JavaScript "properly". One of the most head-scratching elements of the languages design is it's implementation of inheritance. Having experience in Ruby, I was really happy to see closures and dynamic typing; but for the life of me can't figure out what benefits are to be had from object instances using other instances for inheritance.

Sunday, April 8, 2012

Access parent"s parent from javascript object



Somthing like







var life= {

users : {

guys : function(){ this.SOMTHING.mameAndDestroy(this.girls); },

girls : function(){ this.SOMTHING.kiss(this.boys); },

},

mameAndDestroy : function(group){ },

kiss : function(group){ }

};







this.SOMTHING is what I imagine the format is, but it might not be. What will step back up to the parent of an object?



Source: Tips4all

Wednesday, March 7, 2012

Closures in PHP… what, precisely, are they and when would you need to use them?


So I'm programming along in a nice, up to date, object oriented fashion. I regularly make use of the various aspects of OO programming that PHP implements but I am wondering when might I need to use closures. Any experts out there that can shed some light on when it would be useful to implement closures?

How can you organize the code for a game to fit the MVC pattern?


I'm a freshman in college going for my computer science degree... I've programmed plenty the last several years but just lately I've been getting more into theoretical ideas about organizing code, design patterns, differences in languages, etc.

Is it bad practice to make a setter return "this”?


Is it a good or bad idea to make setters in java return "this"?

Tuesday, February 28, 2012

Dynamic binding == late binding in Java or not?


In different sources i've read different things on the topic. For example Wikipedia says:

Friday, February 17, 2012

JS Object, how to access objects from within myself


So, i see no reason why this isn't working but i am at a wall and frustrated. Why can't i call this.myself from within the wyr.message.close function? Maybe my understanding of this is scewed but i was sure this is referring to the object itself, not the function.

Tuesday, February 14, 2012

Object Oriented Programming: More than just basic objects


I seem to find all documentation regarding OOP too basic or too advanced. I'm trying to solve a specific problem and I can't get a nice solution without having to use Singletons or global instances or the such.