Search Results

Search found 25346 results on 1014 pages for 'framework design'.

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

  • Business Layer Design in J2EE Project

    - by user63157
    Currently the project on which I am working is being developed with Spring, Hibernate and struts. The business layer consists of simple java beans with no behavior in them only properties and getter and setter methods, the services are written on them which operates on them and call DAO layer methods and all. My questions is that is it object oriented way of designing or simply the procedure way in which the data and the functions on which they operate are not together. Please provide your thoughts and inputs on how the business logic is design and implemented in j2ee application, is the domain model contains business methods or are they simply dumb objects which have only data and services written on to them.

    Read the article

  • design for interruptable operations

    - by tpaksu
    I couldn't find a better topic but here it is; 1) When user clicks a button, code starts t work, 2) When another button is clicked, it would stop doing whatever it does and start to run the second button's code, 3) Or with not user interaction, an electrical power down detected from a connected device, so our software would cancel the current event and start doing the power down procedure. How is this design mostly applied to code? I mean "stop what you are doing" part? If you would say events, event handlers etc. how do you bind a condition to the event? and how do you tell the program without using laddered if's to end it's process? method1(); if (powerdown) return; method2(); if (powerdown) return; etc.

    Read the article

  • Unit Testing in Entity Framework 4 - using CreateSourceQuery

    - by Adam
    There are many great tutorials on abstracting your EF4 context so that it can be tested against (without involving a DB). Two great (and similar) examples are here: http://blogs.msdn.com/b/adonet/archive/2009/12/17/walkthrough-test-driven-development-with-the-entity-framework-4-0.aspx (oops, not enough rep. points to post second URL) basically you wind up querying your repository using linq-to-objects while testing, and linq-to-entities while running, and usually they behave the same, but when you start hitting more advanced functionality, problems arise. Here's the question. When using linq-to-objects against IObjectSet (ie, unit testing), CreateSourceQuery returns null, which will probably cause your entire query to crash and burn. ie O = db.Orders.First(); O.OrderItems.CreateSourceQuery().ToList(); Is there a way to get CreateSourceQuery to just return the underlying collection, rather than null when working with collections? Unfortunately EntityCollection is sealed, and so cannot be mocked. This isn't really the end or the world if EF4 won't let you abstract things to this level, I just wanted to make sure there wasn't something I was missing.

    Read the article

  • Cleanest RESTful design for purely "action" calls?

    - by Josh Handel
    Hello all, I am sticking my toe in the RESTful waters and I just can't find a "satisfactory" solution to how to handle truely "action" oriented calls on a RESTful service? My quandry can be broken down into two parts. 1) Transactional calls: I understand the idea of having an ActionTransactor that you get a resource too with a post, update the parameters and then commit with a PUT (as described all over the place and in the Orilly RESTful Web services book).. But I struggle with the idea of keeping URLs with states present for ever.. If we really honestly don't need to keep a transaction for ever can we kill the resource URI? do URIs need to be perminate or can they be transiant URIs that expire 2) Non transactional calls: these might be calls to perform some workflow that spans multiple resources but having a resource just doesn't make since.. An example might be to re-generating some calculated ans cached value like a large aggreget or re-indexing blog or some such "purely" action. Anyways, I'm curious about the communities thoughts on this... Thus far, I've read that Overloading Post is the cleanest way to handle part 2.. But there is an equal amount of argument against that approach as well. And (to me) its not self documenting which I though was one of the key design goals of RESTful APIs.

    Read the article

  • Taking the data mapper approach in Zend Framework

    - by Seeker
    Let's assume the following tables setup for a Zend Framework app. user (id) groups (id) groups_users (id, user_id, group_id, join_date) I took the Data Mapper approach to models which basically gives me: Model_User, Model_UsersMapper, Model_DbTable_Users Model_Group, Model_GroupsMapper, Model_DbTable_Groups Model_GroupUser, Model_GroupsUsersMapper, Model_DbTable_GroupsUsers (for holding the relationships which can be seen as aentities; notice the "join_date" property) I'm defining the _referenceMap in Model_DbTable_GroupsUsers: protected $_referenceMap = array ( 'User' => array ( 'columns' => array('user_id'), 'refTableClass' => 'Model_DbTable_Users', 'refColumns' => array('id') ), 'App' => array ( 'columns' => array('group_id'), 'refTableClass' => 'Model_DbTable_Groups', 'refColumns' => array('id') ) ); I'm having these design problems in mind: 1) The Model_Group only mirrors the fields in the groups table. How can I return a collection of groups a user is a member of and also the date the user joined that group for every group? If I just added the property to the domain object, then I'd have to let the group mapper know about it, wouldn't I? 2) Let's say I need to fetch the groups a user belongs to. Where should I put this logic? Model_UsersMapper or Model_GroupsUsersMapper? I also want to make use of the referencing map (dependent tables) mechanism and probably use findManyToManyRowset or findDependentRowset, something like: $result = $this->getDbTable()->find($userId); $row = $result->current(); $groups = $row->findManyToManyRowset( 'Model_DbTable_Groups', 'Model_DbTable_GroupsUsers' ); This would produce two queries when I could have just written it in a single query. I will place this in the Model_GroupsUsersMapper class. An enhancement would be to add a getGroups method to the Model_User domain object which lazily loads the groups when needed by calling the appropriate method in the data mapper, which begs for the second question. Should I allow the domain object know about the data mapper?

    Read the article

  • Entity framework entity class mapping with plain .net class

    - by Elan
    I have following in entity framework Table - Country Fields List item Country_ID Dialing_Code ISO_Alpha2 ISO_Alpha3 ISO_Full I would like to map only selected fields from this entity model to my domain class. My domain model class is public class DomainCountry { public int Country_ID { get; set; } public string Dialing_Code { get; set; } public string ISO_3166_1_Alpha_2 { get; set; } } The following will work however insert or update is not possible. In order to get insert or update we need to use ObjectSet< but it will not support in my case. IQueryable<DomainCountry> countries = context.Countries.Select( c => new DomainCountry { Country_ID = c.Country_Id, Dialing_Code = c.Dialing_Code, ISO_3166_1_Alpha_2 = c.ISO_3166_1_Alpha_2 }); It will be really fantastic could someone provide a nice solution for this. Ideally it will be kind of proxy class which will support all the futures however highly customizable i.e. only the columns we want to expose to the outer world

    Read the article

  • Design considerations for temporarily transforming a player into an animal in a role playing game

    - by mikedev
    I am working on a role playing game for fun and to practice design patterns. I would like players to be able to transform themselves into different animals. For example, a Druid might be able to shape shift into a cheetah. Right now I'm planning on using the decorator pattern to do this but my question is - how do I make it so that when a druid is in the cheetah form, they can only access skills for the cheetah? In other words, they should not be able to access their normal Druid skills. Using the decorator pattern it appears that even in the cheetah form my druid will be able to access their normal druid skills. class Druid : Character { // many cool druid skills and spells void LightHeal(Character target) { } } abstract class CharacterDecorator : Character { Character DecoratedCharacter; } class CheetahForm : CharacterDecorator { Character DecoratedCharacter; public CheetahForm(Character decoratedCharacter) { DecoratedCharacter= decoratedCharacter; } // many cool cheetah related skills void CheetahRun() { // let player move very fast } } now using the classes Druid myDruid = new Druid(); myDruid.LightHeal(myDruid); // casting light heal here is fine myDruid = new CheetahForm(myDruid); myDruid.LightHeal(myDruid); // casting here should not be allowed Hmmmm...now that I think about it, will myDruid be unable to us the Druid class spells/skills unless the class is down-casted? But even if that's the case, is there a better way to ensure that myDruid at this point is locked out from all Druid related spells/skills until it is cast back to a Druid (since currently it's in CheetahForm)

    Read the article

  • Entity Framework 4 and SYSUTCDATETIME ()

    - by GIbboK
    Hi, I use EF4 and C#. I have a Table in my DataBase (MS SQL 2008) with a default value for a column SYSUTCDATETIME (). The Idea is to automatically add Date and Time as soon as a new record is Created. I create my Conceptual Model using EF4, and I have created an ASP.PAGE with a DetailsView Control in INSERT MODE. My problems: When I create a new Record. EF is not able to insert the actual Date and Time value but it inserts instead this value 0001-01-01 00:00:00.00. I suppose the EF is not able to use SYSUTCDATETIME () defined in my DataBase Any idea how to solve it? Thanks Here my SQL script CREATE TABLE dbo.CmsAdvertisers ( AdvertiserId int NOT NULL IDENTITY CONSTRAINT PK_CmsAdvertisers_AdvertiserId PRIMARY KEY, DateCreated dateTime2(2) NOT NULL CONSTRAINT DF_CmsAdvertisers_DateCreated DEFAULT sysutcdatetime (), ReferenceAdvertiser varchar(64) NOT NULL, NoteInternal nvarchar(256) NOT NULL CONSTRAINT DF_CmsAdvertisers_NoteInternal DEFAULT '' ); My Temporary solution: Please guys help me on this e.Values["DateCreated"] = DateTime.UtcNow; More info here: http://msdn.microsoft.com/en-us/library/bb387157.aspx How to use the default Entity Framework and default date values http://msdn.microsoft.com/en-us/library/dd296755.aspx

    Read the article

  • Mapping composite foreign keys in a many-many relationship in Entity Framework

    - by Kirk Broadhurst
    I have a Page table and a View table. There is a many-many relationship between these two via a PageView table. Unfortunately all of these tables need to have composite keys (for business reasons). Page has a primary key of (PageCode, Version), View has a primary key of (ViewCode, Version). PageView obviously enough has PageCode, ViewCode, and Version. The FK to Page is (PageCode, Version) and the FK to View is (ViewCode, Version) Makes sense and works, but when I try to map this in Entity framework I get Error 3021: Problem in mapping fragments...: Each of the following columns in table PageView is mapped to multiple conceptual side properties: PageView.Version is mapped to (PageView_Association.View.Version, PageView_Association.Page.Version) So clearly enough, EF is having a complain about the Version column being a common component of the two foreign keys. Obviously I could create a PageVersion and ViewVersion column in the join table, but that kind of defeats the point of the constraint, i.e. the Page and View must have the same Version value. Has anyone encountered this, and is there anything I can do get around it? Thanks!

    Read the article

  • What is the best software design to use in this scenario

    - by domdefelice
    I need to generate HTML snippets using jQuery. The creation of those snippets depends on some data. The data is stored server-side, in session (where PHP is used). At the moment I achieved this - retrieving the data from the server via AJAX in form of JSON - and building the snippets via specific javascript functions that read those data The problem is that the complexity of the data is getting bigger and hence the serialization into JSON is getting even more difficult since I can't do it automatically. I can't do it automatically because some information are sensible so I generate a "stripped" version to send to the client. I know it is difficult to understand without any code to read, but I am hoping this is a common scenario and would be glad for any tip, suggestion or even design-pattern you can give me. Should I store both a complete and a stripped data on the server and then use some library to automatically generate the JSON from the stripped data? But this also means I have to get the two data synchronized. Or maybe I could move the logic server-side, this way avoiding sending the data. But this means sending javascript code (since I rely on jQuery). Maybe not a good idea. Feel free to ask me more details if this is not clear. Thank you for any help

    Read the article

  • Ruby and duck typing: design by contract impossible?

    - by davetron5000
    Method signature in Java: public List<String> getFilesIn(List<File> directories) similar one in ruby def get_files_in(directories) In the case of Java, the type system gives me information about what the method expects and delivers. In Ruby's case, I have no clue what I'm supposed to pass in, or what I'll expect to receive. In Java, the object must formally implement the interface. In Ruby, the object being passed in must respond to whatever methods are called in the method defined here. This seems highly problematic: Even with 100% accurate, up-to-date documentation, the Ruby code has to essentially expose its implementation, breaking encapsulation. "OO purity" aside, this would seem to be a maintenance nightmare. The Ruby code gives me no clue what's being returned; I would have to essentially experiment, or read the code to find out what methods the returned object would respond to. Not looking to debate static typing vs duck typing, but looking to understand how you maintain a production system where you have almost no ability to design by contract. Update No one has really addressed the exposure of a method's internal implementation via documentation that this approach requires. Since there are no interfaces, if I'm not expecting a particular type, don't I have to itemize every method I might call so that the caller knows what can be passed in? Or is this just an edge case that doesn't really come up?

    Read the article

  • Implementation/interface inheritance design question.

    - by Neil G
    I would like to get the stackoverflow community's opinion on the following three design patterns. The first is implementation inheritance; the second is interface inheritance; the third is a middle ground. My specific question is: Which is best? implementation inheritance: class Base { X x() const = 0; void UpdateX(A a) { y_ = g(a); } Y y_; } class Derived: Base { X x() const { return f(y_); } } interface inheritance: class Base { X x() const = 0; void UpdateX(A a) = 0; } class Derived: Base { X x() const { return x_; } void UpdateX(A a) { x_ = f(g(a)); } X x_; } middle ground: class Base { X x() const { return x_; } void UpdateX(A a) = 0; X x_; } class Derived: Base { void UpdateX(A a) { x_ = f(g(a)); } } I know that many people prefer interface inheritance to implementation inheritance. However, the advantage of the latter is that with a pointer to Base, x() can be inlined and the address of x_ can be statically calculated.

    Read the article

  • Social Media Java Design Problem

    - by jboyd
    I need to put something together quickly that will take blog posts and place them on social media sites, the requirements are as follows: Blog Entries are independent records that already exist, they have a published date and a modified date, the blog entry application cannot be changed, at least not substantially A new blog entry, or update needs to be sent to social media sites I currently do not need to update or delete social media communications if the blog entry is edited, or deleted, though I may need to later My design problems here are as follows: how do I know the status of each update how can I figure out what blog entry updates and postings have already been sent out? how can I quickly poll the blog entry table for postings that haven't yet been sent out? Avoiding looking at each Entry record from the DB as an object and asking if it's been sent already. That would be too slow. I cannot hook into any Blog Entry update code, my only option would be to create a trigger that an update queues something to be processed I'm looking for general guiding principles here, the biggest problem I'm having is coming up with any reasonable way to figure out if a blog entry should be sent to our social media sites in the first place

    Read the article

  • Zend Framework Application: module dependencies

    - by takeshin
    How do you handle dependencies between modules in Zend Framework to create reusable, drop-in modules? E.g. I have Newsletter module, which allows users to subscribe, providing e-mail address. Next, I plan to add Blog module, which allows to subscribe to posts by e-mail (it obviously duplicates some functionality of the newsletter, but the e-mails addresses are stored in User model). Next one is the Forum module, with the same subscribe to post functionality. But I want to have ability to use these modules independent to each one, i.e. application with newsletter alone, newsletter with blog, comibnation two or three modules at once. This is pretty common, e.g. the same story with search feature. I want to have search module, with options to search in all data, blog data or forum data if available. Is there any design pattern for this? Do I have to add some moduleExists($moduleMame), or provide some interface or abstract classes, some base controller pattern, similar for each module?

    Read the article

  • Issue with class design to model user preferences for different classes

    - by Mulone
    Hi all, I'm not sure how to design a couple of classes in my app. Basically that's a situation: each user can have many preferences each preference can be referred to an object of different classes (e.g. album, film, book etc) the preference is expressed as a set of values (e.g. score, etc). The problem is that many users can have preferences on the same objects, e.g.: John: score=5 for filmid=apocalypsenow Paul: score=3 for filmid=apocalypsenow And naturally I don't want to duplicate the object film in each user. So I could create a class called "preference" holding a score and then a target object, something like: User{ hasMany preferences } Preference{ belongsTo User double score Film target Album target //etc } and then define just one target. Then I would create an interface for the target Classes (album, film etc): Interface canBePreferred{ hasMany preferences } And implement all of those classes. This could work, but it looks pretty ugly and it would requires a lot of joins to work. Do you have some patterns I could use to model this nicely? Cheers, Mulone

    Read the article

  • Entity Framework - Store parent reference on child relationship (one -> many)

    - by contactmatt
    I have a setup like this: [Table("tablename...")] public class Branch { public Branch() { Users = new List<User>(); } [Key] public int Id { get; set; } public string Name { get; set; } public List<User> Users { get; set; } } [Table("tablename...")] public class User { [Key] public int Id {get; set; } public string Username { get; set; } public string Password { get; set; } [ForeignKey("ParentBranch")] public int? ParentBranchId { get; set; } // Is this possible? public Branch ParentBranch { get; set; } // ??? } Is it possible for the User to know what parent branch it belongs to? The code above is not working. Entity Framework version 5.0 .NET 4.0 c#

    Read the article

  • Abstract Design Pattern implementation

    - by Pathachiever11
    I started learning design patterns a while ago (only covered facade and abstract so far, but am enjoying it). I'm looking to apply the Abstract pattern to a problem I have. The problem is: Supporting various Database systems using one abstract class and a set of methods and properties, which then the underlying concrete classes (inheriting from abstract class) would be implementing. I have created a DatabaseWrapper abstract class and have create SqlClientData and MSAccessData concrete class that inherit from the DatabaseWrapper. However, I'm still a bit confused about how the pattern goes as far as implementing these classes on the Client. Would I do the following?: DatabaseWrapper sqlClient = new SqlClientData(connectionString); This is what I saw in an example, but that is not what I'm looking for because I want to encapsulate the concrete classes; I only want the Client to use the abstract class. This is so I can support for more database systems in the future with minimal changes to the Client, and creating a new concrete class for the implementations. I'm still learning, so there might be a lot of things wrong here. Please tell me how I can encapsulate all the concrete classes, and if there is anything wrong with my approach. Many Thanks! PS: I'm very excited to get into software architecture, but still am a beginner, so take it easy on me. :)

    Read the article

  • Question about design (inheritance, polymorphism)

    - by Dan
    Hi, I have a question about a problem I'm struggling with. Hope you can bear with me. Imagine I have an Object class representing the base class of a hierarchy of physical objects. Later I inherit from it to create an Object1D, Object2D and Object3D classes. Each of these derived classes will have some specific methods and attributes. For example, the 3d object might have functionality to download a 3d model to be used by a renderer. So I'd have something like this: class Object {}; class Object1D : public Object { Point mPos; }; class Object2D : public Object { ... }; class Object3D : public Object { Model mModel; }; Now I'd have a separate class called Renderer, which simply takes an Object as argument and well, renders it :-) In a similar way, I'd like to support different kinds of renderers. For instance, I could have a default one that every object could rely on, and then provide other specific renderers for some kind of objects: class Renderer {}; // Default one class Renderer3D : public Renderer {}; And here comes my problem. A renderer class needs to get an Object as an argument, for example in the constructor in order to retrieve whatever data it needs to render the object. So far so good. But a Renderer3D would need to get an Object3D argument, in order to get not only the basic attributes but also the specific attributes of a 3d object. Constructors would look like this: CRenderer(Object& object); CRenderer3D(Object3D& object); Now how do I specify this in a generic way? Or better yet, is there a better way to design this? I know I could rely on RTTI or similar but I'd like to avoid this if possible as I feel there is probably a better way to deal with this. Thanks in advance!

    Read the article

  • Objective-c design advice for use of different data sources, swapping between test and live

    - by user200341
    I'm in the process of designing an application that is part of a larger piece of work, depending on other people to build an API that the app can make use of to retrieve data. While I was thinking about how to setup this project and design the architecture around it, something occurred to me, and I'm sure many people have been in similar situations. Since my work is depending on other people to complete their tasks, and a test server, this slows work down at my end. So the question is: What's the best practice for creating test repositories and classes, implementing them, and not having to depend on altering several places in the code to swap between the test classes and the actual repositories / proper api calls. Contemplate the following scenario: GetDataFromApiCommand *getDataCommand = [[GetDataFromApiCommand alloc]init]; getDataCommand.delegate = self; [getDataCommand getData]; Once the data is available via the API, "GetDataFromApiCommand" could use the actual API, but until then a set of mock data could be returned upon the call of [getDataCommand getData] There might be multiple instances of this, in various places in the code, so replacing all of them wherever they are, is a slow and painful process which inevitably leads to one or two being overlooked. In strongly typed languages we could use dependency injection and just alter one place. In objective-c a factory pattern could be implemented, but is that the best route to go for this? GetDataFromApiCommand *getDataCommand = [GetDataFromApiCommandFactory buildGetDataFromApiCommand]; getDataCommand.delegate = self; [getDataCommand getData]; What is the best practices to achieve this result? Since this would be most useful, even if you have the actual API available, to run tests, or work off-line, the ApiCommands would not necessarily have to be replaced permanently, but the option to select "Do I want to use TestApiCommand or ApiCommand". It is more interesting to have the option to switch between: All commands are test and All command use the live API, rather than selecting them one by one, however that would also be useful to do for testing one or two actual API commands, mixing them with test data. EDIT The way I have chosen to go with this is to use the factory pattern. I set up the factory as follows: @implementation ApiCommandFactory + (ApiCommand *)newApiCommand { // return [[ApiCommand alloc]init]; return [[ApiCommandMock alloc]init]; } @end And anywhere I want to use the ApiCommand class: GetDataFromApiCommand *getDataCommand = [ApiCommandFactory newApiCommand]; When the actual API call is required, the comments can be removed and the mock can be commented out. Using new in the message name implies that who ever uses the factory to get an object, is responsible for releasing it (since we want to avoid autorelease on the iPhone). If additional parameters are required, the factory needs to take these into consideration i.e: [ApiCommandFactory newSecondApiCommand:@"param1"]; This will work quite well with repositories as well.

    Read the article

  • Upgrading Entity Framework 1.0 to 4.0 to include foreign keys

    - by duthiega
    Currently I've been working with Entity Framework 1.0 which is located under a service façade. Below is one of the save methods I've created to either update or insert the device in question. This currently works but, I can't help feel that its a bit of a hack having to set the referenced properties to null then re-attach them just to get an insert to work. The changedDevice already holds these values, so why do I need to assign them again. So, I thought I'll update the model to EF4. That way I can just directly access the foreign keys. However, on doing this I've found that there doesn't seem to be an easy way to add the foreign keys except by removing the entity from the diagram and re-adding it. I don't want to do this as I've already been through all the entity properties renaming them from the DB column names. Can anyone help? /// <summary> /// Saves the non network device. /// </summary> /// <param name="nonNetworkDeviceDto">The non network device dto.</param> public void SaveNonNetworkDevice(NonNetworkDeviceDto nonNetworkDeviceDto) { using (var context = new AssetNetworkEntities2()) { var changedDevice = TransformationHelper.ConvertNonNetworkDeviceDtoToEntity(nonNetworkDeviceDto); if (!nonNetworkDeviceDto.DeviceId.Equals(-1)) { var originalDevice = context.NonNetworkDevices.Include("Status").Include("NonNetworkType").FirstOrDefault( d => d.DeviceId.Equals(nonNetworkDeviceDto.DeviceId)); context.ApplyAllReferencedPropertyChanges(originalDevice, changedDevice); context.ApplyCurrentValues(originalDevice.EntityKey.EntitySetName, changedDevice); } else { var maxNetworkDevice = context.NonNetworkDevices.OrderBy("it.DeviceId DESC").First(); changedDevice.DeviceId = maxNetworkDevice.DeviceId + 1; var status = changedDevice.Status; var nonNetworkType = changedDevice.NonNetworkType; changedDevice.Status = null; changedDevice.NonNetworkType = null; context.AttachTo("DeviceStatuses", status); if (nonNetworkType != null) { context.AttachTo("NonNetworkTypes", nonNetworkType); } changedDevice.Status = status; changedDevice.NonNetworkType = nonNetworkType; context.AddToNonNetworkDevices(changedDevice); } context.SaveChanges(); } }

    Read the article

  • C# MultiThread Safe Class Design

    - by Robert
    I'm trying to designing a class and I'm having issues with accessing some of the nested fields and I have some concerns with how multithread safe the whole design is. I would like to know if anyone has a better idea of how this should be designed or if any changes that should be made? using System; using System.Collections; namespace SystemClass { public class Program { static void Main(string[] args) { System system = new System(); //Seems like an awkward way to access all the members dynamic deviceInstance = (((DeviceType)((DeviceGroup)system.deviceGroups[0]).deviceTypes[0]).deviceInstances[0]); Boolean checkLocked = deviceInstance.locked; //Seems like this method for accessing fields might have problems with multithreading foreach (DeviceGroup dg in system.deviceGroups) { foreach (DeviceType dt in dg.deviceTypes) { foreach (dynamic di in dt.deviceInstances) { checkLocked = di.locked; } } } } } public class System { public ArrayList deviceGroups = new ArrayList(); public System() { //API called to get names of all the DeviceGroups deviceGroups.Add(new DeviceGroup("Motherboard")); } } public class DeviceGroup { public ArrayList deviceTypes = new ArrayList(); public DeviceGroup() {} public DeviceGroup(string deviceGroupName) { //API called to get names of all the Devicetypes deviceTypes.Add(new DeviceType("Keyboard")); deviceTypes.Add(new DeviceType("Mouse")); } } public class DeviceType { public ArrayList deviceInstances = new ArrayList(); public bool deviceConnected; public DeviceType() {} public DeviceType(string DeviceType) { //API called to get hardwareIDs of all the device instances deviceInstances.Add(new Mouse("0001")); deviceInstances.Add(new Keyboard("0003")); deviceInstances.Add(new Keyboard("0004")); //Start thread CheckConnection that updates deviceConnected periodically } public void CheckConnection() { //API call to check connection and returns true this.deviceConnected = true; } } public class Keyboard { public string hardwareAddress; public bool keypress; public bool deviceConnected; public Keyboard() {} public Keyboard(string hardwareAddress) { this.hardwareAddress = hardwareAddress; //Start thread to update deviceConnected periodically } public void CheckKeyPress() { //if API returns true this.keypress = true; } } public class Mouse { public string hardwareAddress; public bool click; public Mouse() {} public Mouse(string hardwareAddress) { this.hardwareAddress = hardwareAddress; } public void CheckClick() { //if API returns true this.click = true; } } }

    Read the article

  • Using design-patterns to transform web-service model classes into local model classes and vise versa

    - by Daniil Petrov
    There is a web-application built with play framework 1.2.7. It contains less than 10 model classes. The main purpose of the application is a lightweight access to a complex remote application (more than 50 model classes). The remote application has its own SOAP API and we use it for synchronization of data. There is a scheduled job in the web-app which makes requests to the remote app. It gets bunches of objects from the remote model and populates corresponding objects of the local model. Currently, there are two groups of classes - the local model and the remote model (generated from wsdl schema). It is not allowed to make any modifications to the remote model. Transformations are being made in the scheduled job class. When it gets objects from the remote app it creates local objects. Recently, it was decided to add a possibility to modify the remote objects. It requires more transformations on our side. We need to transform from remote to local model when reading objects and from local to remote when changing objects. I wonder if this would be possible to use some design-patterns to reduce a number of transformations?

    Read the article

  • Object oriented design importance

    - by user5507
    I started studying Object Oriented Design and Modelling using the this book by James Rumbaugh. It uses a tool called Object Modeling Technique (OMT). I have certain newbie questions. I searched the net, but couldn't get answers The book is pretty old. Don't know why the school told me to learn this. I know OMT is a predecessor of the Unified Modeling Language (UML). So its a waste? Whether the concepts change very much when we move from OMT to UML? I know OMT has Object, Dynamic and Functional Model. Wikipedia says UML is compatible with OMT and UML is a model too. As per wikipedia the UML models are Static and Dynamic and they are represented by different diagrams like class, object, activity, sequence..... I couldn't find the equivalence of this in OMT. I read that there are many object oriented development methods like OMT, Booch,.... Which one is used by Industry ? Where could I get a comparison of different Object oriented development methods?

    Read the article

  • Design pattern for window management in a Java Swing app

    - by Lord Torgamus
    I've just started creating my very first little Java Swing app. When the program opens, it brings up a single, simple window with a label and a couple buttons. Clicking one of those buttons is supposed to wipe out the welcome screen and replace it with a totally different panel. I'm not sure what the best way to create that functionality is. One method would be to pass my JFrame as an argument into... just about every other component, but that feels hacky to me. Or, there's making each panel double as an action listener, but that doesn't seem right, either. Is there a design pattern I should be applying here? "Replace the contents of the main — and only — window" must be a reasonably common operation. A name for the pattern would be enough; I can use Google on my own from there. (I wouldn't say no to a longer explanation, though.)

    Read the article

  • Which of these design patterns is superior?

    - by durron597
    I find I tend to design class structures where several subclasses have nearly identical functionality, but one piece of it is different. So I write nearly all the code in the abstract class, and then create several subclasses to do the one different thing. Does this pattern have a name? Is this the best way for this sort of scenario? Option 1: public interface TaxCalc { String calcTaxes(); } public abstract class AbstractTaxCalc implements TaxCalc { // most constructors and fields are here public double calcTaxes(UserFinancials data) { // code double diffNumber = getNumber(data); // more code } abstract protected double getNumber(UserFinancials data); protected double initialTaxes(double grossIncome) { // code return initialNumber; } } public class SimpleTaxCalc extends AbstractCalc { protected double getNumber(UserFinancials data) { double temp = intialCalc(data.getGrossIncome()); // do other stuff return temp; } } public class FancyTaxCalc extends AbstractTaxCalc { protected double getNumber(UserFinancials data) { int temp = initialCalc(data.getGrossIncome()); // Do fancier math return temp; } } Option 2: This version is more like the Strategy pattern, and should be able to do essentially the same sorts of tasks. public class TaxCalcImpl implements TaxCalc { private final TaxMath worker; public DummyImpl(TaxMath worker) { this.worker = worker; } public double calcTaxes(UserFinancials data) { // code double analyzedDouble = initialNumber; int diffNumber = worker.getNumber(data, initialNumber); // more code } protected int initialTaxes(double grossIncome) { // code return initialNumber; } } public interface TaxMath { double getNumber(UserFinancials data, double initial); } Then I could do: TaxCalc dum = new TaxCalcImpl(new TaxMath() { @Override public double getNumber(UserFinancials data, double initial) { double temp = data.getGrossIncome(); // do math return temp; }); And I could make specific implementations of TaxMath for things I use a lot, or I could make a stateless singleton for certain kinds of workers I use a lot. So the question I'm asking is: Which of these patterns is superior, when, and why? Or, alternately, is there an even better third option?

    Read the article

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