What is a "Mutable class" in OOP?
The standard class...is it mutable or not? ...
The standard class...is it mutable or not? ...
In the current project, there are lots of GetData() method, which get different kind of data from hand written database at run time, and set them in different fields in a class. The projects then have such methods. void GetData(Datatype type, int& value); void GetData(Datatype type, double& value); void GetData(Datatype type, long& valu...
Many years ago when I didn't know much about object oriented design I heard one guy said something like "How can you write a text editor without polymorphism?" I didn't know much about OOP and so I couldn't judge how wise that though was or ask any specific questions at that time. Now, after many years of software development (mostly C+...
Considering architecture.... I normally have a shopping cart class with addItem and removeItem methods (amongst a couple of others). However in the spirit of real world shananigans carts should be acted on by customers - therefore should the addtoCart / removefromCart not be a method of the customer? OR should I have an itermediate Cu...
Hi, I have been writing a lot of code for work in PHP/MySQL. So far it has all been procedural making use of functions for functionality occuring multiple times/places. Starting to find some of the site hard to manage - time to go OO. I want to learn about MVC with object oriented PHP & MySQL. I have some experience in Java and MVC but...
If I have an object 'Hotel' which has a few set properties and I pass it to another object which populates more of its properties and then releases it will the first class see these values? ...
I have an abstract base class that has a Property on it that I would like to prevent both hiding, aka new, and override on. public abstract class DomainObject { public bool IsDeleted { get; set; } } public class BankAccount : DomainObject { public bool IsDeleted { get; set; } } The issue is: I need BankAccount to inherit from...
I know very little about OOP, so maybe my question is silly, but still.... Can you access object-oriented (OO) API from procedural (non-OO) languages? For example, Win32 API is not OO, but I know there is a wrapper for C++ to make it OO. But is it possible to do it both ways? I ask because I don't like OO languages; I learned C by prog...
i'd like to do some cleanup whenever an instance is deleted at runtime, but not during garbage collection that happens on exit. in the example below, when c is deleted, a file is removed, and this is what i want; however, that file is also removed when the program exits, and this is NOT what i want. class C: def __del__(self): os...
Hi all, I am from c# object oriented background and which to work similar priniciples in javascript. Any good I articles that could help with me research? This is an example i put together for a Product Javascript object: function Product() { this.reset = function () { this.id = 0; this.name = ''; } } Product....
Hello, class User { private $_var_1 = 10; private $_var_2 = 20; private function _preExecute() { //do something here before executing sub-class's method } private function _postExecute() { //do something here after executing sub-class's method } private function _anyMethod() { echo "Hello!"; } public f...
I have a private method in my Rails app to connect to Amazon S3, execute a passed block of code, then close the connection to S3. It looks like so; def S3 AWS::S3::Base.establish_connection!( :access_key_id => 'Not telling', :secret_access_key => 'Really not telling' ) data = yield AWS::S3::Base.disconnect data end...
EDIT: Question Answered. Thanks deceze! I know you can assign a function's return value to a variable and use it, like this: function standardModel() { return "Higgs Boson"; } $nextBigThing = standardModel(); echo $nextBigThing; So someone please tell me why the following doesn't work? Or is it just not implemented yet? Am ...
This is my first time working with Objective-C, and I keep trying to create objects of classes I have created in methods of other classes, and it will not work. What I mean is for instance, I will have one main class, and one of the methods does something like this: exampleclass *instance1 = [[exampleclass alloc] init] And it says t...
Hi, I have a set of objects that I want to conform to an interface, say ISpecialObject. However a part of my implementation I want to encapsulate the instantiation trigger of these specialobjects within the implementation of each ISpecialObject. So say for instance I have as list of class types that implement ISpecialObject, I then wan...
Hi, I trying my hands on python. I am trying to implement a crypto class which does enc/dec . In my crypto class i require user to pass 3 args to do the enc dec operations. Till now i was reading key from file and doing the operations. Now i want to provide a generate key function also. But problem is that to call generate keys i dont w...
Let's say I have the following two classes: public class Person { public string Name { get; set; } public string Address { get; set; } } public class Customer: Person { public string CustomerNumber { get; set; } public string PaymentTerms { get; set; } } Now, if I have a person that I want to make a customer, I have, t...
I'm curious what the difference is between the following OOP javascript techniques. They seem to end up doing the same thing but is one considered better than the other? function Book(title) { this.title = title; } Book.prototype.getTitle = function () { return this.title; }; var myBook = new Book('War and Peace'); alert(myBoo...
Hi, I have a package (really just one subroutine) I use frequently to parse config file etc. Basically it looks like this: sub get_settings { my %config; my $config = 'path...'; unless(-r $config) { die("Couldn't read config"); } open CONFIG, '<', $config or die $!; while(...
In my ASP.NET MVC app, I have an interface which acts as the template for several different view models: public interface IMyViewModel { Client Client1 { get; set; } Client Client2 { get; set; } Validator Validate(); } So, my view models are defined like this: public interface MyViewModel1 : IMyViewModel { Client Cli...