I am in the process of rewriting a data driven application in ASP.NET MVC and i am struggling to solve the following problem.
The application allows the user to create one or more documents are to be reviewed by a chain of different type of reviewers.
The reviews are done by users of different roles (Reviewer, Manager, FinanceApprover...
Please consider this example. (PHP)
class Database{
private $result;
private $conn;
function query($sql){
$result = $this->conn->query($sql);
// Set the Database::$result ?? Or return the value and avoid setting property?
return $result;
// $this->result = $result;
}
}
wha...
I have a quite basic question:
When should we decide to use Interface or Class for a specific class?
For example: says we have 2 classes, Customer and Doctor.
In Inheritance (class): we could set these 2 classes to inherit from parent class Person.
Couldn't we do the same with Interface? Says we have InterfacePerson and have both Cus...
I'm confused about the notion of "prototype" in javascript.
When I'm defining an object both of the following seem to work:
myObject = {};
myObject.prototype.method1 = function() { ... };
myObject.prototype.method2 = function() { ... };
myObject.prototype.method3 = function() { ... };
and...
myObject = {};
myObject.method1 = functio...
I want to define a new class that inherit the build in str type, and create a method that duplicates the string contents.
How do I get access to the string value assigned to the object of my new class ?
class str_usr(str):
def __new__(cls, arg):
return str.__new__(cls, arg)
def dub(self):
# H...
Hello! I have created a table in DB with name "member" having field "name", "college", "email", "zid" now I have created a class(in php) like
class member
{
private $name,$college,$email,$zid;
private function adduser
{
//function definition
}
public function autherise($id)
{
//function definition
}
}
now at index page...
I am looking for project ideas for course C#. I will happily appreciate if you can share more than one idea, so I can choose one.
specific to C#
only have learned logic and building course
having basic skills related to C# Windows application
What should I develop that can demonstrate OOP skills?
How do you rate an Information Syst...
Is there a standard convention when designing business objects for providing consumers with a way to discover constraints such as a property's maximum length?
It could be used up in the UI layer to, for example, set a Textbox's MaxLength property according to the maximum length limit back in the business object.
Is there a standard ...
As I add methods to various DB_DataObject classes, I lean towards
Class Example extends DB_DataObject {
function methodx() //start fresh
{
$newObject = DB_DataObject::factory($this->__table);
/* do stuff with $newObject */
}
rather than
function methodx() //use current instance
{
/* do stuff with $this */
}
I've realize...
I have a User class which is created when a user logs in
$user = new User($userId);
Now to check if a user is logged in, I tried doing
if (isset($user)) { // user is logged in
} else { // user is not logged in
}
However, isset() doesn't appear to work for objects? And I've also tried is_object(). Please advise! Hopefully the...
Hi all, I have this doubt for a long time... hope anyone can enlight me.
Suppose I have 3 classes in my model.
abstract class Document {}
class Letter extends Document {}
class Email extends Document {}
and a service class with a method that returns a Document (either a Letter or Email).
class MyService {
public Document getDoc(...
I have been poking around in PHP for OOP and I noticed something... Objects are re-instantiated each time the page is refreshed. The problem is that I want the object to keep certain information in class variables for the whole time that someone is on a website.
Is there some sort of way to keep an
object alive the whole time that
some...
Since there isn't respositories for value objects. How can I load all value objects?
Suppose we are modeling a blog application and we have this classes:
Post (Entity)
Comment (Value object)
Tag (Value object)
PostsRespository (Respository)
I Know that when I save a new post, its tags are saving with it in the same table. But how c...
Some code may say more than a thousand words:
/**
* Represents an amount of a resource
* @param {number} amount
* @param {string} type
*/
function Resource(amount, type) {
var nAmount = amount;
var sType = type;
if (amount < 0) {
throw new IllegalArgumentException("amount has to be positive");
}
/**
...
I'm some what confused as to the difference between accessing an instance variable via self or just by name (when working inside the class).
For instance, take this class:
.h:
@interface Register : NSObject {
NSString *mName;
}
- (id) initWithName:(NSString *) name;
.m:
- (id) initWithName:(NSString *)name
{
if (self == [supe...
What is the better approach for separating definition and implementation, using interfaces or abstract classes?
I actually I don't like mixing reference counted objects with other objects. I imagine that this can become a nightmare when maintaining large projects.
But sometimes I would need to derive a class from 2 or more classes/in...
I'm new to object oriented programming and am slowly learning how to apply it to javascript. So please bear with me. :)
I have two basic objects:
"record" which contains methods for editing a single record from a recordset. (create, save, load, etc.)
"recordList" which contains methods for outputting a paginated list of record titl...
I'm trying to build a GraphBot class that can answer different questions about about an associated graph such as path length, shortest path between two vertices, number of paths passing through a given vertex etc.
I'd like to be able to add new questions without changing any code inside the Bot, it is only responsible for receiving the ...
There are situations where I declare member variables at the top of my class and then also declare a property to access or set that member variable, but I ask myself if the property is necessary if it variable is only going to be accessed and set from within the class and no where else, so what is the advantage of using a property to acc...
For example:
Security.setProperty("ocsp.enable", "true");
And this is used only when a CertPathValidator is used. I see two options for imporement:
again singleton, but with getter and setter for each property
an object containing the properties relevant to the current context:
CertPathValidator.setValidatorProperties(..) (it alread...