Search Results

Search found 1591 results on 64 pages for 'oop criticism'.

Page 11/64 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Given a PHP class would be the best and simplest way to override one or two of its methods with one

    - by racl101
    Here's the objective. I have a PHP class and there are one or two of its methods that I would like to override with my own. As I understand OOP (in PHP and in general) I could write a child class that extends it and overrides the functionality of the methods in question. However, I was wondering if this is the best way of achieving this task and if this is a proper use for child classes or if there is something better in PHP for what I'm trying to do.

    Read the article

  • How to organise input for many classes

    - by Evl-ntnt
    I have one abstract class and many child classes. In child classes are from 2 to 20 members which must be filled by user. What the best way to do this using OOP? Make form for each child class? Or hide and unhide many input elements and labels? Is there some best way? I using WPF and C#

    Read the article

  • Java / MySQL - How to access connection from another class?

    - by Alex
    I'm just getting my head around java (and OOP for that matter), the only thing I am familiar with is MySQL. I need to keep the DB connection open throughout the duration of the application, as well as a server socket. I'm not even sure if they both need separate classes, but here's what I have so far: http://pastebin.com/qzMFFTrY (it wouldn't all go in a code tag) The variable I need is con for line 86.

    Read the article

  • What is the state of the art in OOP?

    - by Ollie Saunders
    I used to do a lot of object-oriented programming and found myself reading up a lot on how to do it well. When C++ was the dominant OOP language there was a very different set of best practices than have emerged since. Some of the newer ideas I know of are BDD, internal DSLs, and the importing of ideas from functional programming. My question is: is there any consensus on the best way to develop object-oriented software today in the more modern languages such as C#, Ruby, and Python? And what are those practices? For instance, I rather like the idea of stateless objects but how many are actually using that in practice? Or, is the state of the art to deemphasize the importance of OOP? This might be the case for some Python programmers but would be difficult for Rubyists.

    Read the article

  • As a tooling/automation developer, can I be making better use of OOP?

    - by Tom Pickles
    My time as a developer (~8 yrs) has been spent creating tooling/automation of one sort or another. The tools I develop usually interface with one or more API's. These API's could be win32, WMI, VMWare, a help-desk application, LDAP, you get the picture. The apps I develop could be just to pull back data and store/report. It could be to provision groups of VM's to create live like mock environments, update a trouble ticket etc. I've been developing in .Net and I'm currently reading into design patterns and trying to think about how I can improve my skills to make better use of and increase my understanding of OOP. For example, I've never used an interface of my own making in anger (which is probably not a good thing), because I honestly cannot identify where using one would benefit later on when modifying my code. My classes are usually very specific and I don't create similar classes with similar properties/methods which could use a common interface (like perhaps a car dealership or shop application might). I generally use an n-tier approach to my apps, having a presentation layer, a business logic/manager layer which interfaces with layer(s) that make calls to the API's I'm working with. My business entities are always just method-less container objects, which I populate with data and pass back and forth between my API interfacing layer using static methods to proxy/validate between the front and the back end. My code by nature of my work, has few common components, at least from what I can see. So I'm struggling to see how I can better make use of OOP design and perhaps reusable patterns. Am I right to be concerned that I could be being smarter about how I work, or is what I'm doing now right for my line of work? Or, am I missing something fundamental in OOP? EDIT: Here is some basic code to show how my mgr and api facing layers work. I use static classes as they do not persist any data, only facilitate moving it between layers. public static class MgrClass { public static bool PowerOnVM(string VMName) { // Perform logic to validate or apply biz logic // call APIClass to do the work return APIClass.PowerOnVM(VMName); } } public static class APIClass { public static bool PowerOnVM(string VMName) { // Calls to 3rd party API to power on a virtual machine // returns true or false if was successful for example } }

    Read the article

  • What makes C so popular in the age of OOP?

    - by GradGuy
    I code a lot both in C and C++ but did not expect C to be the second popular language, slightly behind Java! http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html I'm curious as why, in this age of OOP, C is still all that popular? Note that 4 out of top 5 popular languages are all "modern" object-oriented capable languages. Now I agree that you can do OOP in C to some extend, but that's sort of painful and not quite elegant! (well at least compared to C++ I guess) So what makes C this popular? efficiency? being low-level? or the vast majority of libraries that already exist? ... or something else?

    Read the article

  • How to deal with OOP design problems in interviews?

    - by haps10
    This is a question where I seek guidance from fellow/senior developers to get into my dream company - it's a pioneer in OOP and Agile. I've already failed once to clear an interview. One part I feel most challenging is to come up with a proper Object Oriented design(classes, interfaces, methods, interactions etc.) in a very short time for certain situations like Pacman, Game Of Life and so on. As the problems are unprecedented ones - my approach is mostly to try different things and then make decisions - which they feel is not clear and not what they expect from a developer with 5+ years of experience. I've already studied a few books on patterns, OOP - it didn't help me much and I think it'll take a bit more than that. Could some one please guide on what specifically shall I practice so that I can do better at design problems as above. I want to refine my approach and have a better thought process.

    Read the article

  • PHP OOP: Providing Domain Entities with "Identity"

    - by sunwukung
    Bit of an abstract problem here. I'm experimenting with the Domain Model pattern, and barring my other tussles with dependencies - I need some advice on generating Identity for use in an Identity Map. In most examples for the Data Mapper pattern I've seen (including the one outlined in this book: http://apress.com/book/view/9781590599099) - the user appears to manually set the identity for a given Domain Object using a setter: $UserMapper = new UserMapper; //returns a fully formed user object from record sets $User = $UserMapper->find(1); //returns an empty object with appropriate properties for completion $UserBlank = $UserMapper->get(); $UserBlank->setId(); $UserBlank->setOtherProperties(); Now, I don't know if I'm reading the examples wrong - but in the first $User object, the $id property is retrieved from the data store (I'm assuming $id represents a row id). In the latter case, however, how can you set the $id for an object if it has not yet acquired one from the data store? The problem is generating a valid "identity" for the object so that it can be maintained via an Identity Map - so generating an arbitrary integer doesn't solve it. My current thinking is to nominate different fields for identity (i.e. email) and demanding their presence in generating blank Domain Objects. Alternatively, demanding all objects be fully formed, and using all properties as their identity...hardly efficient. (Or alternatively, dump the Domain Model concept and return to DBAL/DAO/Transaction Scripts...which is seeming increasingly elegant compared to the ORM implementations I've seen...)

    Read the article

  • if statement OOP

    - by Luke
    I have the following code /* Errors exist, have user correct them */ if($form->num_errors > 0) { return 1; //Errors with form } /* No errors, add the new account to the */ else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype)) { return 0; //New user added succesfully } else { return 2; //Registration attempt failed } I want to add the following to it $databases->addLeagueTable($name) This should happen at the same time as addLeagueInformation. Any ideas?

    Read the article

  • OOP function and if statement

    - by Luke
    Not sure if I can ask two questions? If i run the following function in my database class function generateUserArray() { $u = array(); $result = $this->selectAllUsers(); while( $row=mysql_fetch_assoc($result)) { $u[] = $row['username']; } return $u; } Would i call it like this? $u[] = $datebase->generateUserArray(); My second question, will this work: else if($database->addLeagueInformation($subname, $subformat, $subgame, $subseason, $subwindow, $subadmin, $subchampion, $subtype) && $databases->addLeagueTable($name) && $_SESSION['players'] == $subplayers && $comp_name = "$format_$game_$name_$season" && $_SESSION['comp_name'] = $comp_name) Thankyou

    Read the article

  • Beginner's Question about accessing mysql using OOP

    - by user345690
    I am reading the PHP and mySQL web development book and so far been doing all the PHP and mysql using procedural. But then it talks about accessing mysql with objects. This works for me: //I define $db so can connect $query="select * FROM testing"; $result=mysqli_query($db,$query); while($row=mysqli_fetch_array($result)){ //echo the data } But when I try to do it with classes, it doesn't $query="select * FROM testing"; $result=$db->query($query); $row=$result->fetch_assoc(); Do I have to write my own class so it defines what query and fetch_assoc does? Or what?

    Read the article

  • JavaScript OOP problem

    - by Danmark
    I create windows like this: var obj = document.createElement('div'); obj.className = 'window'; obj.style.width = 300 + 'px'; obj.style.height = 200 + 'px'; obj.style.left = 30 + 'px'; obj.style.top = 200 + 'px'; //and so on and what I need is to attach some data to each window. The data will be grabbed via Ajax and displayed in the windows. How should I do it so that each window hold its own unique data? I don't need to display the whole data every time and this data would need be organized before being displayed, so I can't just add it with innerHTML. I need a way to hold it somewhere else where I could easily get it and then display it with innerHTML.

    Read the article

  • Python equivalent of Java's compareTo()

    - by astay13
    I'm doing a project in Python (3.2) for which I need to compare user defined objects. I'm used to OOP in Java, where one would define a compareTo() method in the class that specifies the natural ordering of that class, as in the example below: public class Foo { int a, b; public Foo(int aa, int bb) { a = aa; b = bb; } public int compareTo(Foo that) { // return a negative number if this < that // return 0 if this == that // return a positive number if this > that if (this.a == that.a) return this.b - that.b; else return this.a - that.a; } } I'm fairly new to classes/objects in Python, so I'd like to know what is the "pythonic" way to define the natural ordering of a class?

    Read the article

  • Advice needed from PHP/Cake PHP expert

    - by Hiro
    I'm very new to programming (besides SQL and databases), but I ultimately want to master Cake PHP for web development. Now, given how new I am, I'm rather lost as to how I get started. Down the road, I want to use MVC framework so that I help myself be disciplined in the way I build. However, I know basic knowledge of PHP and OOP PHP are required. So my question is this: what are the right steps to mastering Cake PHP? I don't want to skip critical phases of learning before learning to Cake PHP. At the same time, I don't want to spend more time than required learning PHP if I can learn it directly through Cake PHP knowledge. Any advice would be appreciated.

    Read the article

  • C# Class Design Question

    - by Soo
    This is a super newbie question, I've been programming for a while, but am just learning OOP. I have a class that works with user input via the C# console. There are different methods in this class to gather different input sets. I have another class that takes these input sets and puts them in a database. What is the best way to pass the input from my input class to my database insert class? My guess would be: Array1[] = inputClass.GetParameterSet1(); DatabaseInsertClass.InsertIntoDatabase1(Array1[]); Is there anything wrong with this or is there a better way to do this? Should I even have two classes (The database class could also take the user input)?

    Read the article

  • Can I get an example please?

    - by Doug
    $starcraft = array( "drone" => array( "cost" => "6_0-", "gas" => "192", "minerals" => "33", "attack" => "123", ) "zealot" => array( "cost" => "5_0-", "gas" => "112", "minerals" => "21", "attack" => "321", ) ) I'm playing with oop and I want to display the information in this array using a class, but I don't know how to construct the class to display it. This is what I have so far, and I don't know where to go from here. Am I supposed to use setters and getters? class gamesInfo($game) { $unitname; $cost; $gas; $minerals; $attack; }

    Read the article

  • Undefined Variable in Matlab

    - by OrangeRind
    The Following is the basic skeleton for my MATLAB program. Each box is a class definition. Scroll down for the error. Note: Each Class has a custom constructor which does not require an external parameter The Error Undefined function or variable 'Troom'. Error in == wallwall.wall at 31 function o = wall(Tr) Error in == mainfile at 5 w1 = wall(); This comes when I create an object of Class wall from another file "mainfile" Question Why is this happening? Am I getting wrong in the concepts of OOP for Matlab specific? How do I resolve this? Thanks in Advance!

    Read the article

  • Better explanation of $this-> in this example please

    - by Doug
    Referring to this question: http://stackoverflow.com/questions/2035449/why-is-oop-hard-for-me class Form { protected $inputs = array(); public function makeInput($type, $name) { echo '<input type="'.$type.'" name="'.$name.'">'; } public function addInput($type, $name) { $this->inputs[] = array("type" => $type, "name" => $name); } public function run() { foreach($this->inputs as $array) { $this->makeInput($array['type'], $array['name']; } } } $form = new form(); $this->addInput("text", "username"); $this->addInput("text", "password");** Can I get a better explanation of what the $this->input[] is doing in this part: public function addInput($type, $name) { $this->inputs[] = array("type" => $type, "name" => $name); }

    Read the article

  • Extending mysqli and using multiple classes

    - by Mikk
    Hi, I'm new to PHP oop stuff. I'm trying to create class database and call other classes from it. Am I doing it the right way? class database: class database extends mysqli { private $classes = array(); public function __construct() { parent::__construct('localhost', 'root', 'password', 'database'); if (mysqli_connect_error()) { $this->error(mysqli_connect_errno(), mysqli_connect_error()); } } public function __call($class, $args) { if (!isset($this->classes[$class])) { $class = 'db_'.$class; $this->classes[$class] = new $class(); } return $this->classes[$class]; } private function error($eNo, $eMsg) { die ('MySQL error: ('.$eNo.': '.$eMsg); } } class db_users: class db_users extends database { public function test() { echo 'foo'; } } and how I'm using it $db = new database(); $db->users()->test(); Is it the right way or should it be done another way? Thank you.

    Read the article

  • How should I implement items that are normalized in the Database, in Object Oriented Design?

    - by Jonas
    How should I implement items that are normalized in the Database, in Object Oriented classes? In the database I have a big table of items and a smaller of groups. Each item belong to one group. This is how my database design look like: +----------------------------------------+ | Inventory | +----+------+-------+----------+---------+ | Id | Name | Price | Quantity | GroupId | +----+------+-------+----------+---------+ | 43 | Box | 34.00 | 456 | 4 | | 56 | Ball | 56.50 | 3 | 6 | | 66 | Tin | 23.00 | 14 | 4 | +----+------+-------+----------+---------+ Totally 3000 lines +----------------------+ | Groups | +---------+------+-----+ | GroupId | Name | VAT | +---------+------+-----+ | 4 | Mini | 0.2 | | 6 | Big | 0.3 | +---------+------+-----+ Totally 10 lines I will use the OOP classes in a GUI, where the user can edit Items and Groups in the inventory. It should also be easy to do calculations with a bunch of items. The group information like VAT are needed for the calculations. I will write an Item class, but do I need a Group class? and if I need it, should I keep them in a global location or how do I access it when I need it for Item-calculations? Is there any design pattern for this case?

    Read the article

  • is PHP itself transforming into a framework?

    - by Elzo Valugi
    At the beginning PHP was a scripting language. But after the introduction and improvement of OOP I see more and more objects added to the core. They started with SPL which grew a lot, now we have DOMDocument family, DateTime family which should be part of PECL, Pear or Zend Framework or implemented by each one of us. Shouldn't be php only for build-in functions and all these objects passed to something else? Example. DateTime class is part of the core and I see it very similar with Zend_Date.

    Read the article

  • explaining $this->load->view()

    - by ajsie
    in a controller you can use this method to load a view. but i want to know behind the scenes here. im new to php and frameworks, but i’ve learned the basics of OOP. when $this-view() is made then the method in the current class or the parent class is used. but what does this mean: $this-load-view(). what is the intermediate load? is it a function or is it a property? where is it located? how could it contain view()? grateful for explanation.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >