Let's say I have to model the meals of a diner.
A meal can consist of several "components":
(Fries OR rice OR wedges)
AND (One of six different beverages)
AND (One or two out of seven different sauces OR none at all)
Another meal can consist of:
(Salad OR rice)
AND (Garlic OR no garlic)
Further meals can consist of:
Just fries...
I want to build a small ORM (Object Relational Mapping) framework in PHP. I want to do a mixture of an MVC approach, with the same controller/method/variable approach used by CodeIgniter.
There are a few frameworks out there already which do this, but things like
Form validation
Pagination
CRUD
And AJAX
are very difficult to do in t...
The question says all. Preferably in c# or java.
...
I would like to create an object with a data member using OCaml but do not necessarily want to specify an initial value for the data member. Many examples seem to use a list but I would like to use a single instance of an object type I've created. Is this possible? Thanks.
class bar = object end;;
class foo =
object (self)
val myDataMe...
Folks,
For the n-th time in a row, i'm hitting the same old problem again. It's about "how do I map OOP structures to database tables in a painless way."
Here's a scenario: I have several types of "actors" in my system - workers, employers, contacts. They have certain pieces of functionality in common; other pieces are vastly differen...
Is anyone aware of a such a thing as a SQL writing library for .Net? I'm thinking it would be wrapper for generating queries in an object oriented style. Maybe something like the following:
class SelectQuery : BaseQuery
{
List<Column> SelectedColumns { get; set; }
Table MainTable { get; set; }
List<Join> Joins { get; set; }
...
Recently, I took it upon myself to try and learn OO programming. It has been about 3 months since I started, but I think I might be missing the point because I seem to prefer static methods (which seem 'easier' to me).
Example
Here is what a typical DB query looks like in my code.
$bindings = array(':name'=>$articleName);
Db::query('...
I thought to seek this answer from stackoverflow community that how to decide to go for composition or generalization when we are designing classes.
...
Hi,
Assuming you have a class Photo:
class Photo
{
public string Title {get; set;}
public string FileExtension {get; set;}
public void Save()
{
// Save to backing store here
}
}
Which would be the best place to check whether the values have been set correctly. In the propert setter or the Save method.
Edit: What if ...
Hope I can explain this somewhat decently, as it's blowing a fuse in my brain today. I'm learning TDD in C#, so I'm still trying to rewire my brain to fit it.
Let's say I have a User class, that previously had a static method to retrieve a User object (simplified below).
public static User GetUser(string username)
{
User user = GetU...
I'm a bit confused as to why languages have these. I'm a Java programmer and at the start of my career so Java is the only language I've written in since I started to actually, you know, get it.
So in Java of course we don't have properties and we write getThis() and setThat(...) methods.
What would we gain by having properties?
Than...
Hi, the summary of my question is "I have 2 classes which share a common interface, however the two classes have different behaviour with regard to their properties. One interface throws an exception if the parameter values are invalid the other updates its internal state to handle the invalid values. Is it okay for the two classes to ...
I was reading the GoF book and in the beginning of the prototype section I ready this:
This benefit applies primarily to
languages like C++ that don't treat
classes as first class objects.
I've never used C++ but I do have a pretty good understanding of OO programming, yet, this doesn't really make any sense to me. Can anyone ...
Many times, I find myself having to define a container for multi-dimensional data.
Let's take an example: I have many Chips, each Chip has many Registers, each Register has many Cells, and each Cell has many Transistors.
At some stage of my C++ program I have to read this data, and later I have to use it.
I cannot use any external sto...
Do the "Dependency Inversion Principle" (DIP) and "Design to Interfaces Principle" express the same principle? If not, what would be the difference?
EDIT
To clarify and narrow down the context a bit: by interface I mean a programmatic interface, like a Java interface or a pure abstract base class in C++. No other 'contracts' are involv...
I want to design this system which has two major components:
Base/core stuff. Never changes.
Stuff running on the core. Changes rather frequently.
This is going to be developed in Java, but the problem applies to any classical OO language. How can I replace 2 above in a running system without recompiling 1, and without even stopping ...
The project I'm working on has just hit 4200 lines in the main C# file, which is causing Intellisense to take a few seconds (sometimes up to 6 or so) to respond, during which Visual Studio locks up. I'm wondering how everyone else splits their files and whether there's a consensus.
I tried to look for some guides and found Google's C++...
Continuing from the question that I asked here: C++ multi-dimensional data handling
In my example: I have many Chips, each Chip has many Registers, each Register has many Cells, and each Cell has many Transistors. I asked whether to use one complex STL container for them, or to implement full classes for them. And, as advised, I chose t...
I there a method to allow me to use an array as an object?
I have the following code in my main class
function __construct()
{
require 'config.php';
$this->config = new PHPSO_Config();
}
where the PHPSO_Config class looks something like this
class PHPSO_Config
{
/**
* The administrators email address
*/
...
I have an old project that I'm resurrecting as it were, and it makes heavy use of a Javascript/moo tools event controller that I wrote, and also a few Javascript OOP components that I wrote. It's very heavily pattern and OOP based. Also the components are well decoupled.
Does jQuery have any features like these? And if so what are th...