Introduction:
I'm working on API which provides access to Picasa, Flickr and some other image services.
I have a class WebAlbum (it provides access to nested photos, albums if allowed, and some meta information).
My API allows not only read albums but it also allows to create new albums. In general case in order to create new album AP...
I just want to confirm my understanding of exceptions and how they impact their objects.
If I throw an exception, that halts the processing of a method, correct? So there's no point in doing
if ( some_check() ) {
throw new Exception(...);
} else {
...
}
I should just do this
if ( some_check() ) {
throw new Exception(......
I have a scenario where I have several classes that extend from a common ancestor because they all share common properties and methods. Half of these classes (Group A) contain a property that is not shared by the other half (Group B), so each class in Group A explicitly declares this property rather than the parent class.
e.g.
class ...
Is there a way for a class called inside another to know the name of the outer class?
Example:
class A{
// need to get the name of B
// some stuff
}
class B{
$var = new A;
}
get_parent_class() qon't do the work since B is not a child of A.
Any suggestions?
Edit: Sorry everyone I had to change the question. What I wanted to a...
I am halfway through an OOP project in the finance industry, and I'm looking back at my design decisions. I've solved some problems using patterns, and I'm particularly proud of those, but elsewhere I seem to lack a bit of rigor. My own use cases are extremely high level, since the actual input done by the user doesn't even compare to th...
i try to learn refactoring my codes. i writed a base GridView class. This is:
public static class GridViewUtil
{
public static GridView SendGridView(DataTable ds )
{
GridView gv = new GridView();
gv.DataSource = ds;
gv.DataBind();
gv.HeaderStyle.BackColor = Color.Silver;
...
I'm making the leap to OOP with my PHP. Is there a way to list all active classes and their methods and properties?
...
How can i remove $_SERVER['DOCUMENT_ROOT'] from a string like this
/home/bla/test/pic/photo.jpg
the result should look like this
/test/pic/photo.jpg
I also need to take the photo.jpg from /test/pic/photo.jpg
How can i do that i PHP?
Thank
...
This is a question my interviewer asked me.
My Answer is -
if we assign an object of the derived class to
the reference of the base class , the members of the derived class will eclipse or hide.
he didn't tell it's wrong or right.
I want to confirm it.
...
I want to pass through configuration arguments to a class. These are all the optional vars that go into configuring the class - and should be able to run in any order.
at the moment i just pass through the optional vars the regular way. Supposing the constuctor was like the following:
private var _reqVar:String;
private var _optVar1:St...
When including a class that returns objects of another type, I'm not sure of the best practice when importing the class file for the returned object type. So, if all three classes are in separate files:
class file A imports class file B
class file B imports class file C
class B returns an object of type C to class A
should class A als...
I am interested to see how people deal with decision trees when doing DDD. For example we have a requirement that when persisting new instance of particular type, some "default" associations have to be built (quite a few). User is free to change them later on though. So if one creates a decision table, how do you represent this in you do...
What are the purposes of having private/protected members of a class/structure in object-oriented programming? What's the harm in having all members be public?
...
I am trying to find out the reasons why the class cant be created as a static?
Like
public static class Qwert{
public static void main(String args[]){
int x = 12;
while(x<12){
x--;
}
System.out.println(" the X value is : "+ x);
}
}
...
<?php
//5.2.6
class Sample {
private function PrivateBar() {
echo 'private called<br />';
}
public static function StaticFoo() {
echo 'static called<br />';
$y = new Sample();
$y->PrivateBar();
}
}
Sample::StaticFoo();
?>
The above code will output:
"static called
private called"
Why doe...
Hello,
Reflection API is great thing out there to manipulate the OOP stuff and looks like most of the developers aren't even aware of that or have never used that.
Reflection API Claims:
PHP 5 comes with a complete reflection
API that adds the ability to
reverse-engineer classes, interfaces,
functions, methods and extensions....
In the following example I am able to create a virtual method Show() in the inherited class and then override it in the inheriting class.
I want to do the same thing with the protected class variable prefix but I get the error:
The modifier 'virtual' is not valid
for this item
But since I can't define this variable as virtual/ov...
Hi guys,
Say I have a GUI Java project of something that simulates an ATM machine, and i have classes such as :
- RegisterWindow
- LoginWindow
- MainAccountOptionsWindow
etc, where all the classes are focused around the panels/windows rather than normal OO design. Someone told me that this is a specific design pattern, maybe somet...
I'm probably asking the question badly, so I'm going to give an example. I have a class that is something similar to this:
class myclass {
var $template = array();
var $record = array();
function __construct($template,$record) {
$this->template = ( set = to a database response here );
$this->record = ( set = to a database...
I find myself doing this sort of thing from time to time, and I wonder if it's a design smell, or if there's a better design pattern I can use.
There's a process with a number of steps that is known at compile time, but is likely to change down the road. I capture the commonality in an abstract Step class, write a StepLister that return...