Search Results

Search found 41035 results on 1642 pages for 'object oriented design'.

Page 16/1642 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Handling array passed to object at creation

    - by cecilli0n
    When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array elements from within my class, I do so like $this->row['element'] However, As I continue development, I sometimes forget what exactly is in this passed array.(this itself doesn't seem good) I am wondering if their is a professional approach to dealing with this, Or am I the only one who has these "I wonder whats in the array" thoughts. One approach to tackling this could be that when we originally pass the array, in the constructor, we assign each element of the array to its own variable, but is this considered professional practice? Additionally by doing this, we could make those variables constants, in a attempt at immutability. Overall I am trying to adhere to good software craftsmanship. Regards.

    Read the article

  • Figuring out the Call chain

    - by BDotA
    Let's say I have an assemblyA that has a method which creates an instance of assemblyB and calls its MethodFoo(). Now assemblyB also creates an instance of assemblyC and calls MethodFoo(). So no matter if I start with assemblyB in the code flow or with assemlyA, at the end we are calling that MethodFoo of AssemblyC(). My question is when I am in the MethodFoo() how can I know who has called me? Has it been a call originally from assemblyA or was it from assemlyB? Is there any design pattern or a good OO way of solving this?

    Read the article

  • Subscribe/Publish Model in Web-based Application (c#) - Best Practices for Event Handlers

    - by KingOfHypocrites
    I was recently exposed to a desktop application that uses an publish/subscribe model to handle commands, events, etc. I can't seem to find any good examples of using this in a web application, so I wonder if I am off base in trying to use this for web based development (on the server side)? I'm using asp.net c#. My main question in regards to the design is: When using a publish/subscribe model, is it better to have generic commands/events that pass no parameters and then have the subscribers look at static context objects that contain the data relevant to the event? Or is it better to create custom arguments for every event that contain data related to the event? The whole concept of a global container seems so convenient but at the same time seems to break encapsulation. Any thoughts or best practices from anyone who has implemented this type of model in a web based application? Even suggestions on this model out of the scope of my question are appreciated.

    Read the article

  • Python simulation-scripts architecture

    - by Beastcraft
    Situation: I've some scripts that simulate user-activity on desktop. Therefore I've defined a few cases (workflows) and implemented them in Python. I've also written some classes for interacting with the users' software (e.g. web browser etc.). Problem: I'm a total beginner in software design / architecture (coding isn't a problem). How could I structure what I described above? Providing a library which contains all the workflows as functions, or a separate class/module etc. for each workflow? I want to keep the the workflows simple. The complexity should be hidden in the classes for interacting with the users' software. Are there any papers / books I could read about this, or could you provide some tips? Kind regards, B

    Read the article

  • Designing a single look up entity

    - by altsyset
    In almost every application you have this look up entity that provides a dynamic references. This are things like type, category, etc. These entities will always have id, name, desc So at first I designed different entities for each look up. Like education_type, education_level, degree_type.... But on a second thought I decided to have on entity for each of these kinds of entities. But when I am done with the design and check the relation this entity will be referenced by almost all entities in the system and I don't believe that is appropriate. So What is your take on this? Can you give me some clear pros and cons?

    Read the article

  • Console.log in IE on an object just outputted [object Object]

    - by LookitsPuck
    All, I'm used to debugging JavaScript in Chrome or Firefox just because their built in developer tools are a lot cleaner than IE's. IE8 came along way with the Developer Tools being more polished, but they're still not completely up to snuff. I like being able to step through code as if I was in Visual Studio, and that is pretty nice about IE, however, when trying to do a simple console.log on an object that I have, in Firefox/Chrome/etc. I can actually explore that object. In IE, the console is simply outputting the following: LOG: [object Object] Is there any way to drill down into that object in IE like in Chrome/Firefox/etc.? Thanks all! -Steve

    Read the article

  • Convert table base design to table less design in best way

    - by Brij
    What is the best optimized way to convert following in table less design? the layout should be cross browser compatible and SEO Friendly. <table cellpadding="0" cellspacing="0"> <tr> <td>Row 1 Column 1</td> <td>Row 1 Column 2</td> <td>Row 1 Column 3</td> </tr> <tr> <td colspan="3" align="center">Row 2</td> </tr> <tr> <td>Row 3</td> <td align="right" colspan="2"><img src="test.jpg" alt="test" /></td> </tr> </table>

    Read the article

  • Difference between null==object and object==null

    - by priyank.mp
    Hi I would like to know diff between the above comparisons? I am getting null pointer exception when I check object.getItems() == null. But if I change it to null == object.getItems(), it workes fine. I did look into this http://stackoverflow.com/questions/2938476/what-is-the-difference-between-null-object-and-objectnull-closed But I didnt get satisfactory answer.

    Read the article

  • Software Design & Web Service Design

    - by 001
    I'm about to design my Web service API, most of the functions of my API is basically very simular to my web application. Now the question is, should I create 1 single method and reuse them for both the web application and the web service api? (This seems to be the logical solution, however its very complicated; it's much easier to duplicate the method used by the web application, and keep both separate, ie one method for the web application and one method for the web service.) How do you guys do it? 1) REUSE: one main method and reuse them for both web application and web service application (I like this but it's complicated) WebAppMethodX --uses-- COMMONFUNCTIONMETHOD_X APIMethodX ---uses---- COMMONFUNCTIONMETHOD_X ie common function performs functions such as creating/updating/deleting records etc 2) DUPLICATE: two methods, one method for the web application and one method for the web service. WebAppMethodX APIMethodX

    Read the article

  • Design Question on when to save

    - by Ben
    Hi, I was just after peoples opinion on when the best time to save an object (or collection of objects) is. I appreciate that it can be completely dependent on the situation that you are in but here is my situation. I have a collection of objects "MyCollection" in a grid. You can open each object "MyObject" in an editor dialogue by double clicking on the grid. Selecting "Cancel" on the dialogue will back out any changes you have made, but should selecting "ok" commit those changes back to the database, or should they commit the changes on that object back to the collection and have a save method that iterates through the collection and saves all changed objects? If i have an object "MyParentObject", that contains a collection of childen "MyChildObjectCollection", none of the changes made to each "MyChildObject" would be commited to the database until the "MyParentObject" was saved - this makes sense. However in my current situation, none of the objects in the collection are linked, therefore should the "Ok" on the dialogue commit the changes to the database? Appreciate any opinions on this. Thanks

    Read the article

  • Design Patterns: What is a type

    - by contactmatt
    A very basic question, but after reading the "Design Patterns: Elements of reusable OO Software" book, I'm a little confused. The book states, "An object's type only refers to its interface-the set of request to which it can respond. An object can have many types, and objects of different classes can have the same type." Could someone please better explain what a Type is? I also don't understand how one object can have multiple types...unless the book is speaking of polymorphism....

    Read the article

  • Creating a dummy design before the development starts

    - by NLV
    Hello How can i create a dummy design of an application before the actual development starts? How to simulate the UI of the application. After completing the analysis phase do i need to start the design directly using dev tools or can i create some dummies (even images, using Visio or something) with other tools? Thank you

    Read the article

  • Why is it a good practice to wrap all primitives and Strings?

    - by Amogh Talpallikar
    According to Jeff Bay's Essay on Object Callisthenics, One of the practices is set to be "Wrap all primitives and Strings" Can anyone elaborate on this ? In languages where we already have wrappers for primitives like C# and Java. and In languages where Collections can have generics where you are sure of what type goes into the collection, do we need to wrap string's inside their own classes ? Does it have any other advantage ?

    Read the article

  • Is it a good practice to wrap all primitives and Strings?

    - by Amogh Talpallikar
    According to Jeff Bay's Essay on Object Callisthenics, One of the practices is set to be "Wrap all primitives and Strings" Can anyone elaborate on this ? In languages where we already have wrappers for primitives like C# and Java. and In languages where Collections can have generics where you are sure of what type goes into the collection, do we need to wrap string's inside their own classes ? Does it have any other advantage ?

    Read the article

  • Isn't MVC anti OOP?

    - by m3th0dman
    The main idea behind OOP is to unify data and behavior in a single entity - the object. In procedural programming there is data and separately algorithms modifying the data. In the Model-View-Controller pattern the data and the logic/algorithms are placed in distinct entities, the model and the controller respectively. In an equivalent OOP approach shouldn't the model and the controller be placed in the same logical entity?

    Read the article

  • Object database for website

    - by Damian
    I was planning to use db4o for a website. It's a microblog site with small posts and comments developed in java. The thing is I contacted db4o support asking if db4o would be suitable for a website, and they answered me that only for websites with low concurrency. That means with few requests? So, now I think db4o will not be a good choice. Do you know if there is any object database for java suitable for a website?

    Read the article

  • Learn Domain-Driven Design

    - by Ben Griswold
    I just wrote about how I like to present on unfamiliar topics. With this said, Domain-Driven Design (DDD) is no exception. This is yet another area I knew enough about to be dangerous but I certainly was no expert.  As it turns out, researching this topic wasn’t easy. I could be wrong, but it is as if DDD is a secret to which few are privy. If you search the Interwebs, you will likely find little information about DDD until you start rolling over rocks to find that one great write-up, a handful of podcasts and videos and the Readers’ Digest version of the Blue Book which apparently you must read if you really want to get the complete, unabridged skinny on DDD.  Even Wikipedia’s write-up is skimpy which I didn’t know was possible…   Here’s a list of valuable resources.  If you, too, are interested in DDD, this is a good starting place.  Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans Domain-Driven Design Quickly, by Abel Avram & Floyd Marinescu An Introduction to Domain-Driven Design by David Laribee Talking Domain-Driven Design with David Laribee Part 1, Deep Fried Bytes Talking Domain-Driven Design with David Laribee Part 2, Deep Fried Bytes Eric Evans on Domain Driven Design, .NET Rocks Domain-Driven Design Community Eric Evans on Domain Driven Design Jimmy Nilsson on Domain Driven Design Domain-Driven Design Wikipedia What I’ve Learned About DDD Since the Book, Eric Evans Domain Driven Design, Alt.Net Podcast Applying Domain-Driven Design and Patterns: With Examples in C# and .NET, Jimmy Nilsson Domain-Driven Design Discussion Group DDD: Putting the Model to Work by Eric Evans The Official DDD Site

    Read the article

  • Best way to load application settings

    - by enzom83
    A simple way to keep the settings of a Java application is represented by a text file with ".properties" extension containing the identifier of each setting associated with a specific value (this value may be a number, string, date, etc..). C# uses a similar approach, but the text file must be named "App.config". In both cases, in source code you must initialize a specific class for reading settings: this class has a method that returns the value (as string) associated with the specified setting identifier. // Java example Properties config = new Properties(); config.load(...); String valueStr = config.getProperty("listening-port"); // ... // C# example NameValueCollection setting = ConfigurationManager.AppSettings; string valueStr = setting["listening-port"]; // ... In both cases we should parse strings loaded from the configuration file and assign the ??converted values to the related typed objects (parsing errors could occur during this phase). After the parsing step, we must check that the setting values ??belong to a specific domain of validity: for example, the maximum size of a queue should be a positive value, some values ??may be related (example: min < max), and so on. Suppose that the application should load the settings as soon as it starts: in other words, the first operation performed by the application is to load the settings. Any invalid values for the settings ??must be replaced automatically with default values??: if this happens to a group of related settings, those settings are all set with default values. The easiest way to perform these operations is to create a method that first parses all the settings, then checks the loaded values ??and finally sets any default values??. However maintenance is difficult if you use this approach: as the number of settings increases while developing the application, it becomes increasingly difficult to update the code. In order to solve this problem, I had thought of using the Template Method pattern, as follows. public abstract class Setting { protected abstract bool TryParseValues(); protected abstract bool CheckValues(); public abstract void SetDefaultValues(); /// <summary> /// Template Method /// </summary> public bool TrySetValuesOrDefault() { if (!TryParseValues() || !CheckValues()) { // parsing error or domain error SetDefaultValues(); return false; } return true; } } public class RangeSetting : Setting { private string minStr, maxStr; private byte min, max; public RangeSetting(string minStr, maxStr) { this.minStr = minStr; this.maxStr = maxStr; } protected override bool TryParseValues() { return (byte.TryParse(minStr, out min) && byte.TryParse(maxStr, out max)); } protected override bool CheckValues() { return (0 < min && min < max); } public override void SetDefaultValues() { min = 5; max = 10; } } The problem is that in this way we need to create a new class for each setting, even for a single value. Are there other solutions to this kind of problem? In summary: Easy maintenance: for example, the addition of one or more parameters. Extensibility: a first version of the application could read a single configuration file, but later versions may give the possibility of a multi-user setup (admin sets up a basic configuration, users can set only certain settings, etc..). Object oriented design.

    Read the article

  • bootstrap: Uncaught TypeError: Object [object Object] has no method 'tooltip', 'typeahead'

    - by DarkKnightFan
    I am trying to use the tooltip, typeahead, datepicker features of bootstrap. But I keep getting these errors in the console! Uncaught TypeError: Object [object Object] has no method 'tooltip' Uncaught TypeError: Object [object Object] has no method 'typeahead' This is how my imports look like: <link href="css/bootstrap.css" rel="stylesheet"> <link href="css/datepicker.css" rel="stylesheet"> <link href="css/bootstrap-responsive.css" rel="stylesheet"> <script type="text/javascript" src="js/jquery-1.8.0.js"></script> <script type="text/javascript" src="js/bootstrap.js"></script> <script type="text/javascript" src="js/bootstrap-datepicker.js"></script> <script type="text/javascript" src="js/bootstrap-typeahead.js"></script> <script type="text/javascript" src="js/highcharts.js"></script> <script type="text/javascript" src="js/exporting.js"></script> <link type="text/css" rel="stylesheet" href="css/jquery.dropdown.css" /> <script type="text/javascript" src="js/jquery.dropdown.js"></script> Some sample code: <a class="btn btn-success" data-toggle="modal" href="#payments" rel="tooltip" data-placement="top" title="Record your payments"> <i class="icon-check icon-white"></i> Payments</a> $("#payments").tooltip('show'); Similarly I have code for datepicker and typeahead. any solution?

    Read the article

  • Uncaught TypeError: Property 'dist2' of object [object Object] is not a function

    - by Radu Vlad
    I have this functions that should return me the distance from point p to segment line v-w. The problem i have is after some time i receive the following error: Uncaught TypeError: Property 'dist2' of object [object Object] is not a function. I receive it in distToSegmentSquared directly,not even calling the function dist2().Is it any other dist2() anywhere in jquery?I found none... function sqr(x) { return x * x; } function dist2(v, w) { console.log(v); console.log(w); return sqr(v.x - w.x) + sqr(v.y - w.y); } function distToSegmentSquared(p, v, w) { var l2 = dist2(v, w); if (l2 == 0) return dist2(p, v); var t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2; if (t < 0) return dist2(p, v); if (t > 1) return dist2(p, w); return dist2(p, {x: v.x + t * (w.x - v.x), y: v.y + t * (w.y - v.y)}); } function distToSegment(p, v, w) { return Math.sqrt(distToSegmentSquared(p, v, w)); } The values that are given in for that error are: p: Object x: 461 y: 333 v: Object x: 80 y: 120 w: Object x: 260 y: 120

    Read the article

  • DB Schema for ACL involving 3 subdomains

    - by blacktie24
    Hi, I am trying to design a database schema for a web app which has 3 subdomains: a) internal employees b) clients c) contractors. The users will be able to communicate with each other to some degree, and there may be some resources that overlap between them. Any thoughts about this schema? Really appreciate your time and thoughts on this. Cheers! -- -- Table structure for table locations CREATE TABLE IF NOT EXISTS locations ( id bigint(20) NOT NULL, name varchar(250) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Table structure for table privileges CREATE TABLE IF NOT EXISTS privileges ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, resource_id int(11) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; -- -- Table structure for table resources CREATE TABLE IF NOT EXISTS resources ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, user_type enum('internal','client','expert') NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Table structure for table roles CREATE TABLE IF NOT EXISTS roles ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, type enum('position','department') NOT NULL, parent_id int(11) DEFAULT NULL, user_type enum('internal','client','expert') NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Table structure for table role_perms CREATE TABLE IF NOT EXISTS role_perms ( id int(11) NOT NULL AUTO_INCREMENT, role_id int(11) NOT NULL, privilege_id int(11) NOT NULL, mode varchar(250) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Table structure for table users CREATE TABLE IF NOT EXISTS users ( id int(10) unsigned NOT NULL AUTO_INCREMENT, email varchar(255) NOT NULL, password varchar(255) NOT NULL, salt varchar(255) NOT NULL, type enum('internal','client','expert') NOT NULL, first_name varchar(255) NOT NULL, last_name varchar(255) NOT NULL, location_id int(11) NOT NULL, phone varchar(255) NOT NULL, status enum('active','inactive') NOT NULL DEFAULT 'active', PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; -- -- Table structure for table user_perms CREATE TABLE IF NOT EXISTS user_perms ( id int(11) NOT NULL AUTO_INCREMENT, user_id int(11) NOT NULL, privilege_id int(11) NOT NULL, mode varchar(250) NOT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Table structure for table user_roles CREATE TABLE IF NOT EXISTS user_roles ( id int(11) NOT NULL, user_id int(11) NOT NULL, role_id int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    Read the article

  • Using PDO with MVC

    - by mister martin
    I asked this question at stackoverflow and received no response (closed as duplicate with no answer). I'm experimenting with OOP and I have the following basic MVC layout: class Model { // do database stuff } class View { public function load($filename, $data = array()) { if(!empty($data)) { extract($data); } require_once('views/header.php'); require_once("views/$filename"); require_once('views/footer.php'); } } class Controller { public $model; public $view; function __construct() { $this->model = new Model(); $this->view = new View(); // determine what page we're on $page = isset($_GET['view']) ? $_GET['view'] : 'home'; $this->display($page); } public function display($page) { switch($page) { case 'home': $this->view->load('home.php'); break; } } } These classes are brought together in my setup file: // start session session_start(); require_once('Model.php'); require_once('View.php'); require_once('Controller.php'); new Controller(); Now where do I place my database connection code and how do I pass the connection onto the model? try { $db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_DATABASE.'', DB_USERNAME, DB_PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch(PDOException $err) { die($err->getMessage()); } I've read about Dependency Injection, factories and miscellaneous other design patterns talking about keeping SQL out of the model, but it's all over my head using abstract examples. Can someone please just show me a straight-forward practical example?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >