Search Results

Search found 1449 results on 58 pages for 'oop'.

Page 19/58 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • Where should Nhibernate IPostInsertEventListener go in the 3 tier architecture

    - by Quintin Par
    I have a IPostInsertEventListener implementation like public class NHibernateEventListener : IPostInsertEventListener, IPostUpdateEventListener which catches some entity inserts and does an additional insert to another table for ETL. Essentially it requires references to the Nhibernate, Domain entity and Repository<> Now where do I go about adding this class? If I add it to ApplicationServices I’ll end up referencing Nhibernate at that layer. If I add this to the Data layer, I’ll have to reference Domain (circular). How do I go implementing this class with S#arp principles? Any thoughts?

    Read the article

  • jQuery style Constructors in PHP

    - by McB
    Is there a way to instantiate a new PHP object in a similar manner to those in jQuery? I'm talking about assigning a variable number of arguments when creating the object. For example, I know I could do something like: ... //in my Class __contruct($name, $height, $eye_colour, $car, $password) { ... } $p1 = new person("bob", "5'9", "Blue", "toyota", "password"); But I'd like to set only some of them maybe. So something like: $p1 = new person({ name: "bob", eyes: "blue"}); Which is more along the lines of how it is done in jQuery and other frameworks. Is this built in to PHP? Is there a way to do it? Or a reason I should avoid it?

    Read the article

  • PHP sessions and class members.

    - by JDW
    Ok, messing about with classes in PHP and can't get it to work the way I'm used to as a C++/Java-guy. In the "_init" funtion, if I run a query at the "// query works here" line", everythong works, but in the "getUserID" function, all that happens is said warning... "getUserID" gets called from login.php (they are in the same dir): login.php <?php include_once 'sitehandler.php'; include_once 'dbhandler.php'; session_start(); #TODO: Safer input handling $t_userName = $_POST["name"]; $t_userId = $_SESSION['handler']['db']->getUserID($t_userName); if ($t_userId != -1) { $_SESSION['user']['name'] = $t_userName; $_SESSION['user']['id'] = $t_userId; } //error_log("user: " . $_SESSION['user']['name'] . ", id: ". $_SESSION['user']['id']); header("Location: " . $_SERVER["HTTP_REFERER"]); ? dbhandler.php <?php include_once 'handler.php'; class DBHandler extends HandlerAbstract { private $m_handle; function __construct() { parent::__construct(); } public function test() { #TODO: isdir liquibase #TODO: isfile liquibase-195/liquibase + .bat + execrights $this->m_isTested = true; } public function _init() { if (!$this->isTested()) $this->test(); if (!file_exists('files/data.db')) { #TODO: How to to if host is Windows based? exec('./files/liquibase-1.9.5/liquibase --driver=org.sqlite.JDBC --changeLogFile=files/data_db.xml --url=jdbc:sqlite:files/data.db update'); #TODO: quit if not success } #TODO: Set with default data try { $this->m_handle = new SQLite3('files/data.db'); } catch (Exception $e) { die("<hr />" . $e->getMessage() . "<hr />"); } // query works here $this->m_isSetup = true; } public function teardown() { } public function getUserID($name) { // PHP Warning: SQLite3::prepare(): The SQLite3 object has not been correctly initialised in $t_statement = $this->m_handle->prepare("SELECT id FROM users WHERE name = :name"); $t_statement->bindValue(":name", $name, SQLITE3_TEXT); $t_result = $t_statement->execute(); //var_dump($this->m_handle); return ($t_result)? (int)$t_result['id']: -1; } }

    Read the article

  • When should I use Dependency Injection and when utility methods?

    - by Roman
    I have a Java EE project with Spring IoC container. I've just found in Utils class static method sendMail(long list of params). I don't know why but I feel that it would look better if we had separate class (Spring bean with singleton scope) which will be responsible for sending email. But I can't find any arguments which can prove my position. So, are there any pros (or cons) in using DI in this (rather general) situation?

    Read the article

  • How Can I Learn about Interfaces

    - by BDotA
    I am using C# and I know what are the interfaces and how syntatically use them,etc. but what I have not learned yet is that when I am tasked to write a project, create a component,... How should I learn better about interfaces so when I want to do something I be able to Think about using them in my design...or for example I want to learn about dependency injection or even using mocking objects for testing, these are all related to good understanding of interfaces and know when and how to use them ... Can you plase provide me some good advice, reading,... then can help me with that?

    Read the article

  • My abstract class implements an interface but doesn't implement some of its methods. How do I make i

    - by Stefan Monov
    interface ICanvasTool { void Motion(Point newLocation); void Tick(); } abstract class CanvasTool_BaseDraw : ICanvasTool { protected abstract void PaintAt(Point location); public override void Motion(Point newLocation) { // implementation } } class CanvasTool_Spray : CanvasTool_BaseDraw { protected abstract void PaintAt(Point location) { // implementation } public override void Tick() { // implementation } } This doesn't compile. I could add an abstract method "Tick_Implementation" to CanvasTool_BaseDraw, then implement ICanvasTool.Tick in CanvasTool_BaseDraw with a one-liner that just calls Tick_Implementation. Is this the recommended workaround?

    Read the article

  • Two objects with dependencies for each other. Is that bad?

    - by Kasper Grubbe
    Hi SO. I am learning a lot about design patterns these days. And I want to ask you about a design question that I can't find an answer to. Currently I am building a little Chat-server using sockets, with multiple Clients. Currently I have three classes. Person-class which holds information like nick, age and a Room-object. Room-class which holds information like room-name, topic and a list of Persons currently in that room. Hotel-class which have a list of Persons and a list of Rooms on the server. I have made a diagram to illustrate it (Sorry for the big size!): http://i.imgur.com/Kpq6V.png I have a list of players on the server in the Hotel-class because it would be nice to keep track of how many there are online right now (Without having to iterate through all of the rooms). The persons live in the Hotel-class because I would like to be able to search for a specific Person without searching the rooms. Is this bad design? Is there another way of achieve it? Thanks.

    Read the article

  • Lightweight PHP library alternative to common frameworks

    - by artarad
    Hi hi, I'm looking for a easy to learn php library to use for my coming web app project. I've recently finished a web app with fully handwritten raw php code and it's absolutely hard to be done again for another project. even though I have the recent project code snippets to be used again, but due to their non-structural arrangement (not object oriented), i have no passion to use 'em again. I have no experience with common frameworks like ZF, CakePhp, CodeIgniter, so I think to get my hands on a multipurpose OO library for my web app and the framework learning will be the next step! any suggestion? UPDATE: Many thanks guys, I have not enough time to get through the depth of every lib or framework you have kindly introduced. Since I'm going one step further I'm going to use ZF as famous framework which could provide me more job opportunities perhaps. thankssss :)

    Read the article

  • How do I echo the number of items in an array?

    - by Joel
    A total newbie question I know. I'm sing Zend framework, and sending an array from the controller: $this->view->googleArray = $viewFeedArray; In the view, I have a foreach loop that is populating a table with the array contents. <?php foreach($this->googleArray as $row) { ?> <tr> <td><?php echo $row['when']; ?></td> ... ... </tr> <?php } ?> It all works fine. At the top of the table, I want to list the number of items in the array. Something like (which doesn't work): <?php echo $this->googleArray->totalResults; ?> event(s) found How would I do that? Thanks!

    Read the article

  • Can't declare even the most simple class in PHP - Am I going insane?

    - by Phil
    I'm getting this error whenever I attempt to declare a class: Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home3/foundloc/public_html/booka/page2.php on line 7 (line 7 is the class declaration by the way). Here's the incredibly simple class I am attempting to declare: Class abc { $a = “Hello!”; } Is there some setting on PHP that i need to turn on? I feel like this is one of those 'did you check if the TV is plugged in' type of issues....

    Read the article

  • Does code in the constructor add to code in subclass constructors?

    - by Jeremy Rudd
    Does code in the constructor add to code in subclass constructors? Or does the subclass's constructor override the superclass? Given this example superclass constructor: class Car{ function Car(){ trace("CAR") } } ...and this subclass constructor: class FordCar extends Car{ function FordCar(){ trace("FORD") } } When an instance of FordCar is created, will this trace "Car" and "Ford" ??

    Read the article

  • Single Responsibility Principle usage how can i call sub method correctly?

    - by Phsika
    i try to learn SOLID prencibles. i writed two type of code style. which one is : 1)Single Responsibility Principle_2.cs : if you look main program all instance generated from interface 1)Single Responsibility Principle_3.cs : if you look main program all instance genareted from normal class My question: which one is correct usage? which one can i prefer? namespace Single_Responsibility_Principle_2 { class Program { static void Main(string[] args) { IReportManager raporcu = new ReportManager(); IReport wordraporu = new WordRaporu(); raporcu.RaporHazirla(wordraporu, "data"); Console.ReadKey(); } } interface IReportManager { void RaporHazirla(IReport rapor, string bilgi); } class ReportManager : IReportManager { public void RaporHazirla(IReport rapor, string bilgi) { rapor.RaporYarat(bilgi); } } interface IReport { void RaporYarat(string bilgi); } class WordRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Word Raporu yaratildi:{0}",bilgi); } } class ExcellRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Excell raporu yaratildi:{0}",bilgi); } } class PdfRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("pdf raporu yaratildi:{0}",bilgi); } } } Second 0ne all instance genareted from normal class namespace Single_Responsibility_Principle_3 { class Program { static void Main(string[] args) { WordRaporu word = new WordRaporu(); ReportManager manager = new ReportManager(); manager.RaporHazirla(word,"test"); } } interface IReportManager { void RaporHazirla(IReport rapor, string bilgi); } class ReportManager : IReportManager { public void RaporHazirla(IReport rapor, string bilgi) { rapor.RaporYarat(bilgi); } } interface IReport { void RaporYarat(string bilgi); } class WordRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Word Raporu yaratildi:{0}",bilgi); } } class ExcellRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("Excell raporu yaratildi:{0}",bilgi); } } class PdfRaporu : IReport { public void RaporYarat(string bilgi) { Console.WriteLine("pdf raporu yaratildi:{0}",bilgi); } } }

    Read the article

  • android mobile development performance vs extensibility

    - by mixm
    im developing a game in android, and i've been thinking about subdividing many of the elements of the game (e.g. game objects) into separate classes and sub-classes. but i know that method calls to these objects will cause some overhead. would it be better to improve performance or to improve extensibility?

    Read the article

  • Define data members within constructor

    - by bertsisterwanda
    I have got this little snippet of code, I want to be able to define each array element as a new data member. class Core_User { protected $data_memebers = array( 'id' = '%d', 'email' = '"%s"', 'password' = '"%s"', 'title' = '"%s"', 'first_name' = '"%s"', 'last_name' = '"%s"', 'time_added' = '%d' , 'time_modified' = '%d' , ); function __construct($id = 0, $data = NULL) { foreach($data_memebers as $member){ //protected new data member } }

    Read the article

  • Shortening code

    - by Misiur
    Nah, looks like it was hosting fault. Who can make this code shorter? private function replaceFunc($subject) { foreach($this->func as $t) { preg_match_all('/\{'.$t.'\([a-zA-Z,\']+\)\}/i', $subject, $res); for($j = 0; $j < sizeof($res[0]); $j++) { preg_match('/\([a-zA-Z,\']+\)/i', $res[0][$j], $match); if($match > 0) { $prep = explode(", ", substr($match[0], 1, -1)); $args = array(); for($i = 0; $i < sizeof($prep); $i++) { $args[] = substr($prep[$i], 1, -1); } } else { $args = array(); } $subject = preg_replace('/\{'.$t.preg_quote($match[0]).'\}/i', call_user_func_array($t, $args), $subject); } } return $subject; }

    Read the article

  • Can't get custom error rendering to work in symfony 1.4

    - by hongkildong
    I'm tring to customize error rendering in my form according to this example. Here is my code: if ($this['message']->hasError()) { $error_msg = '<ul>'; foreach ($this['message']->getError() as $error) $error_msg .= "<li>$error</li>"; $error_msg .= '</ul>'; } return $error_msg; but when $this['message'] has error this code returns '<ul></ul>' so it seems foreach ($this['message']->getError() as $error) causes no iterations $this['message']->getError() returns sfValidatorError object - maybe something changed in symfony 1.4 and it isn't iterable anymore... At first I thought that all magic in that example happened because of object being placed in $error by iteration implements __toString() but it seems no iterations happens at all...

    Read the article

  • PHP script loading took over 10 seconds

    - by Misiur
    My again. I've promised to not come back today, but I've got another trouble. http://www.misiur.com/me/ - it took over 10 seconds to load. Whole site code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>{site('title')}</title> <link rel="stylesheet" type="text/css" href="{site('themeDir')}/global.css" /> </head> <body> <div id="site"> <div id="footer"> <p>Site Managment System {site('version')} by <a href="http://www.misiur.com">Misiur</a>. Copyright &copy; 2010-{$currYear}.</p> </div> </div> </body> I think the trouble is in this piece of code: private function replaceFunc($subject) { foreach($this->func as $t) { preg_match_all('/\{'.$t.'\([a-zA-Z,\']+\)\}/i', $subject, $res); for($j = 0; $j < sizeof($res[0]); $j++) { preg_match('/\([a-zA-Z,\']+\)/i', $res[0][$j], $match); if($match > 0) { $prep = explode(", ", substr($match[0], 1, -1)); $args = array(); for($i = 0; $i < sizeof($prep); $i++) { $args[] = substr($prep[$i], 1, -1); } } else { $args = array(); } $subject = preg_replace('/\{'.$t.preg_quote($match[0]).'\}/i', call_user_func_array($t, $args), $subject); } } return $subject; } It has to find functions from array ($this-func), cut out arguments, and call function with them. I think that I've messed up. Help.

    Read the article

  • Is there a simple way to emulate friendship in php 5.3

    - by Itay Moav
    I need some classes to befriend other classes in my system. Lack of this feature made me publicize some methods which shouldn't be public. The consequences of that are that members of my team implement code in a bad and ugly way which causes a mess. Is there a way to define a friendship in php 5.3? (I am aware of http://bugs.php.net/bug.php?id=34044 You might want to vote there if there is no simple solution).

    Read the article

  • What is Object Decomposition?

    - by Mustafa
    Hi everyone, I was trying to understand what object decomposition means and read a lot of stuff on internet but every resource talks in terms of lots of keywords that i couldn't understand. So these resources expect you to know a few terms. I need something that lists the basics of decomposition from scratch. Is it anything more than breaking the design into objects? If no, any description will be appreciated. Thanks in advance

    Read the article

  • about python scripting

    - by kmitnick
    I have this code class HNCS (ThreadingTCPServer): def verify_request(self, request, client_address): for key in connections: if connections[key].client_address[0] == client_address[0]: if client_address[0] != '127.0.0.1': return False return True def welcome(self): return '''______________________________________________________ ------------------------------------------------------ %s ______________________________________________________ ------------------------------------------------------ * Server started %s * Waiting for connections on port %i ''' % (gpl, ctime(), PORT) I only can't figure out the line where it says if connections[key].client_address[0] == client_address[0] how come we used client_address as an attribute after dictionary???

    Read the article

  • Java method overloading + double dispatch

    - by Max
    Can anybody explain in detail the reason the overloaded method print(Parent parent) is invoked when working with Child instance in my test piece of code? Any pecularities of virtual methods or methods overloading/resolution in Java involved here? Any direct reference to Java Lang Spec? Which term describes this behaviour? Thanks a lot. public class InheritancePlay { public static class Parent { public void doJob(Worker worker) { System.out.println("this is " + this.getClass().getName()); worker.print(this); } } public static class Child extends Parent { } public static class Worker { public void print(Parent parent) { System.out.println("Why this method resolution happens?"); } public void print(Child child) { System.out.println("This is not called"); } } public static void main(String[] args) { Child child = new Child(); Worker worker = new Worker(); child.doJob(worker); } }

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >