There is a way to get the total memory PHP is using (memory_get_usage()) but how does one get the size in memory of an individual object?
I'm obviously not talking about count() as I want the number of bytes in a potentially complex data structure.
Is this even possible?
Thanks.
...
Just I am new to Object Modelling.I want to know still there is a need to use Sequence Diagram, Use case Diagram to develop an object model or any other new technology is available?
Update :
CRC (Class,Responsibilites,Collaborator) is very limited ?
...
I often find myself needing reference to an object that is several objects away, or so it seems. The options I see are passing a reference through a middle-man or just making something available statically. I understand the danger of global scope, but passing a reference through an object that does nothing with it feels ridiculous. I'm o...
I'm a brand-newbie to C#, albeit not programming, so please forgive me if I mix things up a bit -- it's entirely unintentional. I've written a fairly simple class called "API" that has several public properties (accessors/mutators). I've also written a testing console application that uses reflection to get an alphabetically list of na...
I know there are LOTS of reasons why you would compose a certain object inside another one. Some schools of thought have made explicit the reasons for architecting a program a certain way e.g. 'data-driven design' or 'domain-driven design'. I'm still a beginner to OOP, and it's often hard for me to understand why one object should be con...
How do you think about data access code like this:
public void AddCusotmer(Cusotmer customer)
{
//save customer into database
...
// save payment type
SavePaymentType(customer);
//save other data
...
}
private void SavePaymentType(Customer customer)
{
if(customer.PaymentType is XXXPayment)
{
var payment ...
Hi i have a little collection of classes some of which should be globally accessible.
I found something similar in Zend_Registry, but reading its code i cant understand how a call to a static function could return an initialized instance of a class...
i need to do something like:
<?php
//index.php
$obj = new myUsefulObject();
$obj->lo...
Hello,
I'm working on developing an application that talks to a family of USB sensors. I've created a basic implementation that utilizes a class called Sensor. The class contains events and methods that allow for interaction with the sensor (there is also a threaded task processor involved but I'll go with a simple example).
My issue ...
I'm writing a game where the mouse-driven controller object clicks on a player object to have it do something.
There are 2 ways of initiating the interaction between mouse and player:
Controller calls player's function:
Controller listens for mouse events. When a mouse click occurs anywhere onscreen, the controller searches all obje...
I do not have much experience using frameworks or anything so that leaves me with little experience using Models (MVC). I have no interest whatsoever in using a framework at the moment. I am working on a website and I am trying to model some objects but I'm not sure exactly how I should be designing the class.
For instance, right now I ...
I have a class that creates a static array of all properties, using a static constructor. I also have a function -- GetNamesAndTypes() -- that lists the name & type of each property in that array.
Now I want to create another instance-level function -- GetNamesAndTypesAndValues() -- that displays the name & type of each property in the...
I wrote a application in MFC with C++. I need to write a class which can save all the data loaded from the database, These data might contain every kind of data type, such as int, string, byte, boolean, datetime and so on. We might filter, exchange columns, or sort on these data. For example:
int int string bool double float .... st...
Are circular class dependencies bad from a coding style point of view?
Example:
In a database application we have two classes, one encapsulating information about a single database (DBInfo) and one class which can create a database connection. (ConnFactory)
DBInfo has a getConnection method which uses ConnFactoryto create a connection...
Can't imagine this isn't a dupe but I can't seem find any previously matching questions.
I have a generic method
public T GetSetting<T>(Guid userId) where T : ISetting, new()
This in it's turn calls a generic method
public static ISetting CreateSetting<T>(IDictionary<string, object> data) where T:ISetting, new()
The signatures...
If there's any open source code that does this already I'm interested in hearing about it. But I haven't seen it yet so I'm trying to roll my own.
Example:
variable x = compareCriteriaBetween 3 and 6
variable y = compareCriteriaLesserThanOrEqual 5
The difficult part for me is finding an elegant way to compare the compareCriteria and ...
In response to What is your longest-held programming assumption that turned out to be incorrect? question, one of the wrong assumptions was:
That private member variables were
private to the instance and not the
class.
(Link)
I couldn't catch what he's talking about, can anyone explain what is the wrong/right about that with a...
I have one file with a form, that includes another to process that form. The file with the form calls a function in the included file to write data to the database, and then I return an $insert_id from that post so I can reference it in the output.
For example, when you fill out the form on the page, the data is sent to the db from a s...
Hi all,
I'm after some guidance on how to approach coding a problem, I don't want to jump straight into coding without think about it as I need it to be as generic and customisable as possible,
The scenario is i have a web service that acts as a gateway to downstream services, with the aim of authenticating and authorising SOAP messag...
I haven't actually done this yet, and maybe I don't need to, but it made sense to me. I have a baseclass, say BaseClass, where I have several derived classes, say Derived1,Derived2,Derived3. I have several operations that apply only to one particular function, namely generating a PDF. My idea was take all of those methods (some are abstr...
Hi all.
What are Object Serialization and Deserialization? What difference does Serialization have with normal techniques like reading an object's properties and then filling a DataRow's columns with them and finally saving the DataRow in DB ?
Thank you
...