Search Results

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

Page 7/58 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • How Does a Login system generally work with OOP?

    - by fakingfantastic
    Sorry if this is a badly formed question, but I'm trying to make my web applications (using PHP) more OO. *EDIT* I'm developing the Framework myself */EDIT* Everything is great so far, I've made a Front Controller system that taps into a MVC system. The FC figures out what page you want, loads the specific page Controller (*EDIT* which extends an abstract Controller Object */EDIT*), which gets anything it needs from Models, and then calls the appropriate View. Very basic. But now, I need to make an admin section (quasi-CMS). How does a login system fit into the grand scheme of things? Do you set controllers as needing a login? If so, how? What If you only want certain views of a controller requiring login? Thanks in advance.

    Read the article

  • OOP question about functions that struck me all of a sudden.

    - by Nitesh Panchal
    Hello, May be my question is stupid. But i would like to get it cleared. We know that functions are loaded in memory only once and when you create new objects, only instance variables gets created, functions are never created. My question is, say suppose there is server and all clients access a method named createCustomer(). Say suppose all clients do something which fired createCustomer on server. So, if the method is in middle of execution and new client fires it. Will the new request be put on wait? or new request also will start executing the method? How does it all get managed when there is only one copy of function in memory? No book mentions answers to this type of questions. So i am posting here where i am bound to get answers :).

    Read the article

  • Learning OOP in PHP, trying to refactor my code. Can't connect to database anymore.

    - by Cortopasta
    Thought I understood how classes work, then I tried this code: class user { var $dbcon; var $dbinfo; var $con; var $error; function dbConnect() { $this->dbinfo['server'] = "localhost"; $this->dbinfo['database'] = "foolish_faith"; $this->dbinfo['user'] = "user"; $this->dbinfo['password'] = "password"; $this->con = "mysql:host=".$dbinfo['server']."; dbname=".$dbinfo['database']; $this->dbcon = new PDO($con, $dbinfo['user'], $dbinfo['password']); $this->dbcon->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->error = $this->dbcon->errorInfo(); if ($error[0] != "") { print "Error!"; print_r($error); } } } Now it just spits out this error: Fatal error: Uncaught exception 'PDOException' with message 'invalid data source name' in E:\PortableApps\xampp\htdocs\dbcon.php:24 Stack trace: #0 E:\PortableApps\xampp\htdocs\dbcon.php(24): PDO-__construct('', NULL, NULL) #1 E:\PortableApps\xampp\htdocs\login.php(4): user-dbConnect() #2 {main} thrown in E:\PortableApps\xampp\htdocs\dbcon.php on line 24 Can anybody see what I'm doing wrong, as I'm sure it has to do with my lack of knowledge when it comes to classes?

    Read the article

  • Is there any good reason for private methods existence in C# (and OOP in general)?

    - by Piotr Lopusiewicz
    I don't mean to troll but I really don't get it. Why would language designers allow private methods instead of some naming convention (see __ in Python) ? I searched for the answer and usual arguments are: a) To make the implementation cleaner/avoid long vertical list of methods in IDE autocompletion b) To announce to the world which methods are public interface and which may change and are just for implementation purpose c) Readability Ok so now, all of those could be achieved by naming all private methods with __ prefix or by "private" keyword which doesn't have any implications other than be information for IDE (don't put those in autocompletion) and other programers (don't use it unless you really must). Hell, one could even require unsafe-like keyword to access private methods to really discourage this. I am asking this because I work with some c# code and I keep changing private methods to public for test purposes as many in-between private methods (like string generators for xml serialization) are very useful for debugging purposes (like writing some part of string to log file etc.). So my question is: Is there anything which is achieved by access restriction but couldn't be achieved by naming conventions without restricting the access ?

    Read the article

  • php, OOP dosent allow me to fetch multilingual content?

    - by user3138823
    i have written bellow class for my database connection. class dbConnection { protected $dbLink; public $db_host = "127.0.0.1"; public $db_user = "root"; public $db_pass = ""; public $db_name = "answer"; function connect() { try { $dbLink = new PDO('mysql:host='.$this->db_host.';dbname='.$this->db_name, $this->db_user, $this->db_pass); return $dbLink; } catch (PDOException $e) { return $e->getMessage(); } } } but in my databse i have multilingual content ( collection type = utf8_general_ci ). when i try to fetch data it returns ???? instead of real data. please can any one tell me how can i improve my class to work with multilingual contents. Thanks.

    Read the article

  • HTML5 point and click adventure game code structure with CreateJS

    - by user1612686
    I'm a programming beginner. I made a tiny one scene point and click adventure game to try to understand simple game logic and came up with this: CreateJS features prototypes for creating bitmap images, sprites and sounds objects. I create them and define their properties in a corresponding function (for example images(); spritesheets(), sounds()...). I then create functions for each animation sequence and "game level" functions, which handle user interactions and play the according animations and sounds for a certain event (when the level is complete, the current level function calls the next level function). And I end up with quite the mess. What would be the "standard (if something like that exists)" OOP approach to structure simple game data and interactions like that? I thought about making game.images, game.sprites, game.sounds objects, which contain all the game data with its properties using CreateJS constructors. game.spriteAnimations and game.tweenAnimations objects for sprite animations and tweens and a game.levelN object, which communicates with a game.interaction object, processing user interaction. Does this make any sense? How do you structure your simple game code? Thanks in advance!

    Read the article

  • Staying OO and Testable while working with a database

    - by Adam Backstrom
    What are some OOP strategies for working with a database but keeping thing testable? Say I have a User class and my production environment works against MySQL. I see a couple possible approaches, shown here using PHP: Pass in a $data_source with interfaces for load() and save(), to abstract the backend source of data. When testing, pass a different data store. $user = new User( $mysql_data_source ); $user-load( 'bob' ); $user-setNickname( 'Robby' ); $user-save(); Use a factory that accesses the database and passes the result row to User's constructor. When testing, manually generate the $row parameter, or mock the object in UserFactory::$data_source. (How might I save changes to the record?) class UserFactory { static $data_source; public static function fetch( $username ) { $row = self::$data_source->get( [params] ); $user = new User( $row ); return $user; } } I have Design Patterns and Clean Code here next to me, but I'm struggling to find applicable concepts.

    Read the article

  • How to design Models the correct way: Object-oriented or "Package"-oriented?

    - by ajsie
    I know that in OOP you want every object (from a class) to be a "thing", eg. user, validator etc. I know the basics about MVC, how they different parts interact with each other. However, i wonder if the models in MVC should be designed according to the traditional OOP design, that is to say, should every model be a database/table/row (solution 2)? Or is the intention more like to collect methods that are affecting the same table or a bunch of related tables (solution 1). example for an Address book module in CodeIgniter, where i want be able to "CRUD" a Contact and add/remove it to/from a CRUD-able Contact Group. Models solution 1: bunching all related methods together (not real object, rather a "package") class Contacts extends Model { function create_contact() {) function read_contact() {} function update_contact() {} function delete_contact() {} function add_contact_to_group() {} function delete_contact_from_group() {} function create_group() {} function read_group() {} function update_group() {} function delete_group() {} } Models solution 2: the OOP way (one class per file) class Contact extends Model { private $name = ''; private $id = ''; function create_contact() {) function read_contact() {} function update_contact() {} function delete_contact() {} } class ContactGroup extends Model { private $name = ''; private $id = ''; function add_contact_to_group() {} function delete_contact_from_group() {} function create_group() {} function read_group() {} function update_group() {} function delete_group() {} } i dont know how to think when i want to create the models. and the above examples are my real tasks for creating an Address book. Should i just bunch all functions together in one class. then the class contains different logic (contact and group), so it can not hold properties that are specific for either one of them. the solution 2 works according to the OOP. but i dont know why i should make such a dividing. what would the benefits be to have a Contact object for example. Its surely not a User object, so why should a Contact "live" with its own state (properties and methods). you experienced guys with OOP/MVC, please shed a light on how one should think here in this very concrete task.

    Read the article

  • Building a simple cart using object orientated PHP

    - by James
    I've built basic shopping carts with PHP before but in an attempt to get my feet wet with OOP, I'd like to try using that method. I come from a design background but do understand some basics of OOP but would like to see a tutorial or something simple I could base this on. The site is small and the cart functionality required is very standard. Can anyone offer a link to a decent tutorial or article on building a Cart with PHP OOP, a quick google didn't turn up anything decent.

    Read the article

  • Explain Type Classes in Haskell

    - by Tsubasa Gomamoto
    Hi, I am a C++ / Java programmer and the main paradigm I happen to use in everyday programming is OOP. In some thread I read a comment that Type classes are more intuitive in nature than OOP. Can someone explain the concept of type classes in simple words so that an OOP guy like me can understand it?

    Read the article

  • php OOP, full sample

    - by lolalola
    Hi, On this site I found a lot of cool examples of PHP OOP. Maybe you know where to find complete examples? Guest books, registration forms, blog... When I look at the full model is much easier to understand OOP PHP. As different classes interacting with each other, exchange data How to use the generic class for sending data to the database Thanks

    Read the article

  • So what *did* Alan Kay really mean by the term "object-oriented"?

    - by Charlie Flowers
    Reportedly, Alan Kay is the inventor of the term "object oriented". And he is often quoted as having said that what we call OO today is not what he meant. For example, I just found this on Google: "I made up the term 'object-oriented', and I can tell you I didn't have C++ in mind" - Alan Kay, OOPSLA '97 I vaguely remember hearing something pretty insightful about what he did mean. Something along the lines of "message passing". Do you know what he meant? Can you fill in more details of what he meant and how it differs from today's common OO? Please share some references if you have any. Thanks.

    Read the article

  • I don't get object-oriented programming

    - by Joel J. Adamson
    Note: this question is an edited excerpt from a blog posting I wrote a few months ago. After placing a link to the blog in a comment on Programmers.SE someone requested that I post a question here so that they could answer it. This posting is my most popular, as people seem to type "I don't get object-oriented programming" into Google a lot. Feel free to answer here, or in a comment at Wordpress. What is object-oriented programming? No one has given me a satisfactory answer. I feel like you will not get a good definition from someone who goes around saying “object” and “object-oriented” with his nose in the air. Nor will you get a good definition from someone who has done nothing but object-oriented programming. No one who understands both procedural and object-oriented programming has ever given me a consistent idea of what an object-oriented program actually does. Can someone please give me their ideas of the advantages of object-oriented programming?

    Read the article

  • Pure virtual or abstract, what's in a name?

    - by Steven Jeuris
    While discussing a question about virtual functions on Stack Overflow, I wondered whether there was any official naming for pure (abstract) and non-pure virtual functions. I always relied on wikipedia for my information, which states that pure and non-pure virtual functions are the general term. Unfortunately, the article doesn't back it up with a origin or references. To quote Jon Skeet's answer to my reply that pure and non-pure are the general term used: @Steven: Hmm... possibly, but I've only ever seen it in the context of C++ before. I suspect anyone talking about them is likely to have a C++ background :) Did the terms originate from C++, or were they first defined or implemented in a earlier language, and are they the 'official' scientific terms?

    Read the article

  • Introducing Visual WebGui's XAML programming model extension for web developers

    - by Visual WebGui
    While ASP.NET provides an event base approach it is completely dismissed when working with AJAX and the richness of the server is lost and replaced with JavaScript programming and couple with a very high security risk. Visual WebGui reinstates the power of the server to AJAX development and provides a statefull yet scalable, server centric architecture that provides the benefits and user productivity of AJAX with the security and developer productivity we had before AJAX stormed into our lives. When...(read more)

    Read the article

  • What is a “pretty and proper OO” way for handling sessions and authentication?

    - by asdfqwer
    Is coupling these two concepts a bad approach? As of right now I'm delegating all session handling and whether or not a user desires to logout in my config.inc file. As I was writing my Auth class I started wondering whether or not my Auth class should be taking care of most of the logic in my config.inc. Regardless, I'm sure there's a more elegant way of handling this... Here is what I have in my config.inc (also a large chunk of this code is based on a reply I found on SO except I can't find the source ._.): ini_set('session.name', 'SID'); # session management session_set_cookie_params(24*60*60); // set SID cookie lifetime session_start(); if(isset($_SESSION['LOGOUT']) { session_destroy(); // destroy session data $_SESSION = array(); // destroy session data sanity check setcookie('SID', '', time() - 24*60*60); // destroy session cookie data #header('Location: '.DOCROOT); } elseif(isset($_SESSION['SID_AUTH'])) { // verify user has authenticated if (!isset($_SESSION['SID_CREATED'])) { $_SESSION['SID_CREATED'] = time(); } elseif (time() - $_SESSION['SID_CREATED'] > 6*60*60) { // session started more than 6 hours ago session_regenerate_id(); // reset SID value $_SESSION['SID_CREATED'] = time(); // update creation time } if (isset($_SESSION['SID_MODIFIED']) && (time() - $_SESSION['SID_MODIFIED'] > 12*60*60)) { // last request was more than 12 hours ago session_destroy(); // destroy session data $_SESSION = array(); // destroy session data sanity check setcookie('SID', '', time() - 24*60*60); // destroy session cookie data } $_SESSION['SID_MODIFIED'] = time(); // update last activity time stamp }

    Read the article

  • Models, controllers, and code reuse

    - by user11715
    I have a blog where users can post comments. When creating a comment, various things happen: creating the comment object, associations, persisting sending notification emails to post's author given his preferences sending notification to moderators given their preferences updating a fulltext database for search ... I could put all this in the controller, but what if I want to reuse this code ? e.g. I would like to provide an API for posting comments. I could also put this in the model, but I wonder if I won't lose flexibility by doing so. And would it be acceptable to do all of this from the model layer ? What would you do ?

    Read the article

  • Allocating Entities within an Entity System

    - by miguel.martin
    I'm quite unsure how I should allocate/resemble my entities within my entity system. I have various options, but most of them seem to have cons associated with them. In all cases entities are resembled by an ID (integer), and possibly has a wrapper class associated with it. This wrapper class has methods to add/remove components to/from the entity. Before I mention the options, here is the basic structure of my entity system: Entity An object that describes an object within the game Component Used to store data for the entity System Contains entities with specific components Used to update entities with specific components World Contains entities and systems for the entity system Can create/destroy entites and have systems added/removed from/to it Here are my options, that I have thought of: Option 1: Do not store the Entity wrapper classes, and just store the next ID/deleted IDs. In other words, entities will be returned by value, like so: Entity entity = world.createEntity(); This is much like entityx, except I see some flaws in this design. Cons There can be duplicate entity wrapper classes (as the copy-ctor has to be implemented, and systems need to contain entities) If an Entity is destroyed, the duplicate entity wrapper classes will not have an updated value Option 2: Store the entity wrapper classes within an object pool. i.e. Entities will be return by pointer/reference, like so: Entity& e = world.createEntity(); Cons If there is duplicate entities, then when an entity is destroyed, the same entity object may be re-used to allocate another entity. Option 3: Use raw IDs, and forget about the wrapper entity classes. The downfall to this, I think, is the syntax that will be required for it. I'm thinking about doing thisas it seems the most simple & easy to implement it. I'm quite unsure about it, because of the syntax. i.e. To add a component with this design, it would look like: Entity e = world.createEntity(); world.addComponent<Position>(e, 0, 3); As apposed to this: Entity e = world.createEntity(); e.addComponent<Position>(0, 3); Cons Syntax Duplicate IDs

    Read the article

  • call function between classes [closed]

    - by aziz joh
    hello I have 3 classes class A, B, and C class A is the main class and content the main function also, i call class B and class C in the main as b1,b2 and c1. in class B there is a vector (V) has list of int. and 3 functions Add, get and delete delete. all the thing in the class is public. in class C i have function that need to (B::get) from b. what I want is that how I can make c1 call get of b1 to return the value of the V in b1 after that use add of b2 to add new item in V of b2. Thanks in advance This is an example class a{ int main(){ b b1,b2; c c1; b1.add(10); b1.add(20); c1.start(); }} class b{ vector<int> v; void add(int i){ v.push_back(i)} int get(){int i=v.at(0); return i;} } class c{// take something from b1 and add it to b2 void play(){ int i=b.get();//should take it from b1 b.add(i*2);//should add it to b2 }} please I need your help I been searching to solve this problem for days.

    Read the article

  • MVP Pattern Philsophical Question - Security Checking in UI

    - by Brian
    Hello, I have a philosophical question about the MVP pattern: I have a component that checks whether a user has access to a certain privilege. This privilege turns on or off certain UI features. For instance, suppose you have a UI grid, and for each row that gets bound, I do a security check to see if certain features in the grid should be enabled or disabled. There are two ways to do this: have the UI/view call the component's method, determine if it has access, and enable/disable or show/hide. The other is have the view fire an event to the presenter, have the presenter do the check and return the access back down to the view through the model or through the event arg. As per the MVP pattern, which component should security checks fit into, the presenter or the view? Since the view is using it to determine its accessibility, it seems more fitting in the view, but it is doing database checks and all inside this business component, and there is business logic there, so I can see the reverse argument too. Thoughts? Thanks.

    Read the article

  • PHP ORM style of querying

    - by Petah
    Ok so I have made an ORM library for PHP. It uses syntax like so: *(assume that $business_locations is an array)* Business::type(Business:TYPE_AUTOMOTIVE)-> size(Business::SIZE_SMALL)-> left_join(BusinessOwner::table(), BusinessOwner::business_id(), SQL::OP_EQUALS, Business::id())-> left_join(Owner::table(), SQL::OP_EQUALS, Owner::id(), BusinessOwner::owner_id())-> where(Business::location_id(), SQL::in($business_locations))-> group_by(Business::id())-> select(SQL::count(BusinessOwner::id()); Which can also be represented as: $query = new Business(); $query->set_type(Business:TYPE_AUTOMOTIVE); $query->set_size(Business::SIZE_SMALL); $query->left_join(BusinessOwner::table(), BusinessOwner::business_id(), SQL::OP_EQUALS, $query->id()); $query->left_join(Owner::table(), SQL::OP_EQUALS, Owner::id(), BusinessOwner::owner_id()); $query->where(Business::location_id(), SQL::in($business_locations)); $query->group_by(Business::id()); $query->select(SQL::count(BusinessOwner::id()); This would produce a query like: SELECT COUNT(`business_owners`.`id`) FROM `businesses` LEFT JOIN `business_owners` ON `business_owners`.`business_id` = `businesses`.`id` LEFT JOIN `owners` ON `owners`.`id` = `business_owners`.`owner_id` WHERE `businesses`.`type` = 'automotive' AND `businesses`.`size` = 'small' AND `businesses`.`location_id` IN ( 1, 2, 3, 4 ) GROUP BY `businesses`.`id` Please keep in mind that the syntax might not be prefectly correct (I only wrote this off the top of my head) Any way, what do you think of this style of querying? Is the first method or second better/clearer/cleaner/etc? What would you do to improve it?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >