Search Results

Search found 13727 results on 550 pages for 'oo design'.

Page 33/550 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Flow-Design Cheat Sheet &ndash; Part II, Translation

    - by Ralf Westphal
    In my previous post I summarized the notation for Flow-Design (FD) diagrams. Now is the time to show you how to translate those diagrams into code. Hopefully you feel how different this is from UML. UML leaves you alone with your sequence diagram or component diagram or activity diagram. They leave it to you how to translate your elaborate design into code. Or maybe UML thinks it´s so easy no further explanations are needed? I don´t know. I just know that, as soon as people stop designing with UML and start coding, things end up to be very different from the design. And that´s bad. That degrades graphical designs to just time waste on paper (or some designer). I even believe that´s the reason why most programmers view textual source code as the only and single source of truth. Design and code usually do not match. FD is trying to change that. It wants to make true design a first class method in every developers toolchest. For that the first prerequisite is to be able to easily translate any design into code. Mechanically, without thinking. Even a compiler could do it :-) (More of that in some other article.) Translating to Methods The first translation I want to show you is for small designs. When you start using FD you should translate your diagrams like this. Functional units become methods. That´s it. An input-pin becomes a method parameter, an output-pin becomes a return value: The above is a part. But a board can be translated likewise and calls the nested FUs in order: In any case be sure to keep the board method clear of any and all business logic. It should not contain any control structures like if, switch, or a loop. Boards do just one thing: calling nested functional units in proper sequence. What about multiple input-pins? Try to avoid them. Replace them with a join returning a tuple: What about multiple output-pins? Try to avoid them. Or return a tuple. Or use out-parameters: But as I said, this simple translation is for simple designs only. Splits and joins are easily done with method translation: All pretty straightforward, isn´t it. But what about wires, named pins, entry points, explicit dependencies? I suggest you don´t use this kind of translation when your designs need these features. Translating to methods is for small scale designs like you might do once you´re working on the implementation of a part of a larger design. Or maybe for a code kata you´re doing in your local coding dojo. Instead of doing TDD try doing FD and translate your design into methods. You´ll see that way it´s much easier to work collaboratively on designs, remember them more easily, keep them clean, and lessen the need for refactoring. Translating to Events [coming soon]

    Read the article

  • Component based game engine design

    - by a_m0d
    I have been looking at game engine design (specifically focused on 2d game engines, but also applicable to 3d games), and am interested in some information on how to go about it. I have heard that many engines are moving to a component based design nowadays rather than the traditional deep-object hierarchy. Do you know of any good links with information on how these sorts of designs are often implemented? I have seen evolve your hierarchy, but I can't really find many more with detailed information (most of them just seem to say "use components rather than a hierarchy" but I have found that it takes a bit of effort to switch my thinking between the two models). Any good links or information on this would be appreciated, and even books, although links and detailed answers here would be preferred.

    Read the article

  • Opinions on sensor / reading / alert database design

    - by Mark
    I've asked a few questions lately regarding database design, probably too many ;-) However I beleive I'm slowly getting to the heart of the matter with my design and am slowly boiling it down. I'm still wrestling with a couple of decisions regarding how "alerts" are stored in the database. In this system, an alert is an entity that must be acknowledged, acted upon, etc. Initially I related readings to alerts like this (very cut down) : - [Location] LocationId [Sensor] SensorId LocationId UpperLimitValue LowerLimitValue [SensorReading] SensorReadingId Value Status Timestamp [SensorAlert] SensorAlertId [SensorAlertReading] SensorAlertId SensorReadingId The last table is associating readings with the alert, because it is the reading that dictate that the sensor is in alert or not. The problem with this design is that it allows readings from many sensors to be associated with a single alert - whereas each alert is for a single sensor only and should only have readings for that sensor associated with it (should I be bothered that the DB allows this though?). I thought to simplify things, why even bother with the SensorAlertReading table? Instead I could do this: [Location] LocationId [Sensor] SensorId LocationId [SensorReading] SensorReadingId SensorId Value Status Timestamp [SensorAlert] SensorAlertId SensorId Timestamp [SensorAlertEnd] SensorAlertId Timestamp Basically I'm not associating readings with the alert now - instead I just know that an alert was active between a start and end time for a particular sensor, and if I want to look up the readings for that alert I can do. Obviously the downside is I no longer have any constraint stopping me deleting readings that occurred during the alert, but I'm not sure that the constraint is neccessary. Now looking in from the outside as a developer / DBA, would that make you want to be sick or does it seem reasonable? Is there perhaps another way of doing this that I may be missing? Thanks. EDIT: Here's another idea - it works in a different way. It stores each sensor state change, going from normal to alert in a table, and then readings are simply associated with a particular state. This seems to solve all the problems - what d'ya think? (the only thing I'm not sure about is calling the table "SensorState", I can't help think there's a better name (maybe SensorReadingGroup?) : - [Location] LocationId [Sensor] SensorId LocationId [SensorState] SensorStateId SensorId Timestamp Status IsInAlert [SensorReading] SensorReadingId SensorStateId Value Timestamp There must be an elegant solution to this!

    Read the article

  • Using Moq at Blend design time

    - by adrian hara
    This might be a bit out there, but suppose I want to use Moq in a ViewModel to create some design time data, like so: public class SomeViewModel { public SomeViewModel(ISomeDependency dependency) { if (IsInDesignMode) { var mock = new Mock<ISomeDependency>(); dependency = mock.Object; // this throws! } } } The mock could be set up to do some stuff, but you get the idea. My problem is that at design-time in Blend, this code throws an InvalidCastException, with the message along the lines of "Unable to cast object of type 'Castle.Proxies.ISomeDependencyProxy2b3a8f3188284ff0b1129bdf3d50d3fc' to type 'ISomeDependency'." While this doesn't necessarily look to be Moq related but Castle related, I hope the Moq example helps ;) Any idea why that is? Thanks!

    Read the article

  • Where did System.Design go?

    - by Nilbert
    I am making a C# project in which I am using ScintillaNet, and it says: The referenced assembly "ScintillaNet" could not be resolved because it has a dependency on "System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project. I tried adding a reference to System.Design, but it doesn't exist in my list. Do I need to download it somewhere? I have MS Visual Studio 10.

    Read the article

  • OOP Design for an Economy

    - by waiwai933
    Not sure where to start, so I'm just going to plow in. Let's say I'm trying to represent an economy in OOP. A basic design I've come up with is: class Person{ int $money; // Money someone has in wallet/purse int $bank_account_id; function getAmountOfMoney() function addMoney($amountToAdd) function subtractMoney($amountToSubtract) } class BankAccount{ int $money; // Money in Bank Account int $interest_per_year; function giveInterest() function depositMoney() // Calls $person->subtractMoney() function withdrawMoney() // Calls $person->addMoney() } Are there any design flaws here?

    Read the article

  • A good design pattern for almost similar objects

    - by Sam
    Hello, I have two websites that have an almost identical database schema. the only difference is that some tables in one website have 1 or 2 extra fields that the other and vice versa. I wanted to the same Database Access layer classes to will manipulate both websites. What can be a good design pattern that can be used to handle that little difference. for example, I have a method createAccount(Account account) in my DAO class but the implementation will be slightly different between website A and website B. I know design patterns don't depend on the language but FYI i m working with Perl. Thanks

    Read the article

  • Design pattern for cost calculator app?

    - by Anders Svensson
    Hi, I have a problem that I’ve tried to get help for before, but I wasn’t able to solve it then, so I’m trying to simplify the problem now to see if I can get some more concrete help with this because it is driving me crazy… Basically, I have a working (more complex) version of this application, which is a project cost calculator. But because I am at the same time trying to learn to design my applications better, I would like some input on how I could improve this design. Basically the main thing I want is input on the conditionals that (here) appear repeated in two places. The suggestions I got before was to use the strategy pattern or factory pattern. I also know about the Martin Fowler book with the suggestion to Refactor conditional with polymorphism. I understand that principle in his simpler example. But how can I do either of these things here (if any would be suitable)? The way I see it, the calculation is dependent on a couple of conditions: 1. What kind of service is it, writing or analysis? 2. Is the project small, medium or large? (Please note that there may be other parameters as well, equally different, such as “are the products new or previously existing?” So such parameters should be possible to add, but I tried to keep the example simple with only two parameters to be able to get concrete help) So refactoring with polymorphism would imply creating a number of subclasses, which I already have for the first condition (type of service), and should I really create more subclasses for the second condition as well (size)? What would that become, AnalysisSmall, AnalysisMedium, AnalysisLarge, WritingSmall, etc…??? No, I know that’s not good, I just don’t see how to work with that pattern anyway else? I see the same problem basically for the suggestions of using the strategy pattern (and the factory pattern as I see it would just be a helper to achieve the polymorphism above). So please, if anyone has concrete suggestions as to how to design these classes the best way I would be really grateful! Please also consider whether I have chosen the objects correctly too, or if they need to be redesigned. (Responses like "you should consider the factory pattern" will obviously not be helpful... I've already been down that road and I'm stumped at precisely how in this case) Regards, Anders The code (very simplified, don’t mind the fact that I’m using strings instead of enums, not using a config file for data etc, that will be done as necessary in the real application once I get the hang of these design problems): public abstract class Service { protected Dictionary<string, int> _hours; protected const int SMALL = 2; protected const int MEDIUM = 8; public int NumberOfProducts { get; set; } public abstract int GetHours(); } public class Writing : Service { public Writing(int numberOfProducts) { NumberOfProducts = numberOfProducts; _hours = new Dictionary<string, int> { { "small", 125 }, { "medium", 100 }, { "large", 60 } }; } public override int GetHours() { if (NumberOfProducts <= SMALL) return _hours["small"] * NumberOfProducts; if (NumberOfProducts <= MEDIUM) return (_hours["small"] * SMALL) + (_hours["medium"] * (NumberOfProducts - SMALL)); return (_hours["small"] * SMALL) + (_hours["medium"] * (MEDIUM - SMALL)) + (_hours["large"] * (NumberOfProducts - MEDIUM)); } } public class Analysis : Service { public Analysis(int numberOfProducts) { NumberOfProducts = numberOfProducts; _hours = new Dictionary<string, int> { { "small", 56 }, { "medium", 104 }, { "large", 200 } }; } public override int GetHours() { if (NumberOfProducts <= SMALL) return _hours["small"]; if (NumberOfProducts <= MEDIUM) return _hours["medium"]; return _hours["large"]; } } public partial class Form1 : Form { public Form1() { InitializeComponent(); List<int> quantities = new List<int>(); for (int i = 0; i < 100; i++) { quantities.Add(i); } comboBoxNumberOfProducts.DataSource = quantities; } private void comboBoxNumberOfProducts_SelectedIndexChanged(object sender, EventArgs e) { Service writing = new Writing((int) comboBoxNumberOfProducts.SelectedItem); Service analysis = new Analysis((int) comboBoxNumberOfProducts.SelectedItem); labelWriterHours.Text = writing.GetHours().ToString(); labelAnalysisHours.Text = analysis.GetHours().ToString(); } }

    Read the article

  • C# Language Design: explicit interface implementation of an event

    - by ControlFlow
    Small question about C# language design :)) If I had an interface like this: interface IFoo { int Value { get; set; } } It's possible to explicitly implement such interface using C# 3.0 auto-implemented properties: sealed class Foo : IFoo { int IFoo.Value { get; set; } } But if I had an event in the interface: interface IFoo { event EventHandler Event; } And trying to explicitly implement it using field-like event: sealed class Foo : IFoo { event EventHandler IFoo.Event; } I will get the following compiler error: error CS0071: An explicit interface implementation of an event must use event accessor syntax I think that field-like events is the some kind of dualism for auto-implemented properties. So my question is: what is the design reason for such restriction done?

    Read the article

  • Custom Providers & Design Patterns

    - by Code Sherpa
    Hi. I am using ASP.NET 2.0 and its various providers. I have overridden most of the methods I need and have the following custom providers: ProjectMembershipProvider ProjectProfileProvider ProjectRoleProvider In the design of my project, my intention was to wrap the custom providers in a facade - style design - mixing and matching profiling, membership, and roles in API methods to simplify things for developers. But, I am finding that a lot of the methods in my custom providers don't need to change, really. And, it seems silly to wrap a stand-alone method in another method that does exactly the same thing. So - is my approach wrong? Or, should I allow end - users to instantiate the custom providers when needed and the mix/match api when needed? This seems a bit redundant to me but I can't see another way. Advice appreciated. Thanks.

    Read the article

  • Domain-driven design with Zend

    - by mik
    This question is a continuation of my previous question here http://stackoverflow.com/questions/2122850/zend-models-architecture (big thanks to Bill Karwin). I've made some reading including this article http://weierophinney.net/matthew/archives/202-Model-Infrastructure.html and this question http://stackoverflow.com/questions/373054/how-to-properly-create-domain-using-zend-framework Now I understand, what domain driven design is. But examples are still very simple and poor. They are based on one table and one model. Now, my question is: do they use Domain Model Design in real-world PHP projects? I've been looking for some good documentation about this, but I haven't found anything good enough, that explains how to manage several tables and transfer them to Domain Objects. As long as I know, there is Hibernate library, that has this features in Java, but what should I use in PHP (Zend Framework)?

    Read the article

  • Design from scratch - building classes

    - by Tony
    Hi All, I've started a new project where I'm writing a WPF business application, but I'm having trouble with the design. The database was easy to put together, but I'm not sure how I have to go about the designing the application itself. The main thing that I find hard is the code design. I've decided that the MVVM pattern is very applicable for this application, but how do I go about deciding what classes to build and how things go from there? Does anyone have some guidelines I could use? This is a standard business application that just stores and retrieves data. Some data queries will also need to be performed.

    Read the article

  • Service design or access to another process

    - by hotyi
    I have a cache service,it's works as .net remoting, i want to create another windows service to clean up the that cache service by transfer the objects from cache to files. because they are in separate process, is their any way i could access that cache service or do i have to expose a method from the cache service to do that clean up work? the "clean up" means i want to serialize the object from Cache to file and these saved file will be used for further process. let me explain this application more detail. the application is mainly a log service to log all the coming request and these request will be saved to db for further data mining. we have 2 design for this log system 1) use MSMQ, but seems it's performance is not good enough, we don't use it. 2) we design a cache service, each request will be saved into the cache, and we need another function to clean up the cache by serialize the object to file.

    Read the article

  • Web design process with CSS - during or after?

    - by SyaZ
    Which is the better practice? Add CSS during web designing you can see the result (or close) as early as possible and make required changes. You also know how many divs or spans you might need (eg to make curved cross-browser hover background). But as you add more and more components to the page sometimes things get hack-ish as you need to patch here and there to get the exact design required. Add CSS after finishing page design you can see the page overall structure as it is well, without styles. You get to see how accessible your site is, and modify it right away if it's not good enough (unlike the former case where you may break multiple CSS rules). Plus after you finished it, you only need to spend most of the time to alter only the CSS file, which is good to get the momentum going. Granted I have never tried the latter approach, but am seriously considering it for my next project if I can see convincing reasons -- or if it's no good at all. Thanks.

    Read the article

  • design using a readonly class in c#

    - by edosoft
    Hi Small design question here. I'm trying to develop a calculation app in C#. I have a class, let's call it InputRecord, which holds 100s of fields (multi dimensional arrays) This InputRecordclass will be used in a number of CalculationEngines. Each CalculcationEngine can make changes to a number of fields in the InputRecord. These changes are steps needed for it's calculation. Now I don't want the local changes made to the InputRecord to be used in other CalculcationEngine's classes. The first solution that comes to mind is using a struct: these are value types. However I'd like to use inheritance: each CalculationEngine needs a few fields only relevant to that engine: it's has it's own InputRecord, based on BaseInputRecord. Can anyone point me to a design that will help me accomplish this?

    Read the article

  • UI Design Choices and How to Implement Them

    - by AKRamkumar
    I am making an application that is a dashboard/widget host. I am using MEF to load the plugins and I have a ui Concept Idea like this: http://i42.tinypic.com/scb6nd.png Is this a good design choice? How would I implement the Navigation? Is there any Design Patter you would reccomend for this? Note: My contract interface is this. public interface IDashboardPlugin { public string Name{get;} public string Description{get;} public string Author{get;} public UIElement UI{get;} }

    Read the article

  • Design patterns and interview question

    - by user160758
    When I was learning to code, I read up on the design patterns like a good boy. Long after this, I started to actually understand them. Design discussions such as those on this site constantly try to make the rules more and more general, which is good. But there is a line, over which it becomes over-analysis starts to feed off itself and as such I think begins to obfuscate the original point - for example the "What's Alternative to Singleton" post and the links contained therein. http://stackoverflow.com/questions/1300655/whats-alternative-to-singleton I say this having been asked in both interviews I’ve had over the last 2 weeks what a singleton is and what criticisms I have of it. I have used it a few times for items such as user data (simple key-value eg. last file opened by this user) and logging (very common i'm sure). I've never ever used it just to have what is essentially global application data, as this is clearly stupid. In the first interview, I reply that I have no criticisms of it. He seemed disappointed by this but as the job wasn’t really for me, I forgot about it. In the next one, I was asked again and, as I wanted this job, I thought about it on the spot and made some objections, similar to those contained in the post linked to above (I suggested use of a factory or dependency injection instead). He seemed happy with this. But my problem is that I have used the singleton without ever using it in this kind of stupid way, which I had to describe on the spot. Using it for global data and the like isn’t something I did then realised was stupid, or read was stupid so didn’t do, it was just something I knew was stupid from the start. Essentially I’m supposed to be able to think of ways of how to misuse a pattern in the interview? Which class of programmers can best answer this question? The best ones? The medium ones? I'm not sure.... And these were both bright guys. I read more than enough to get better at my job but had never actually bothered to seek out criticisms of the most simple of the design patterns like this one. Do people think such questions are valid and that I ought to know the objections off by heart? Or that it is reasonable to be able to work out what other people who are missing the point would do on the fly? Or do you think I’m at least partially right that the question is too unsubtle and that the questions ought to be better thought out in order to make sure only good candidates can answer. PS. Please don’t think I’m saying that I’m just so clever that I know everything automatically - I’ve learnt the hard way like everyone else. But avoiding global data is hardly revolutionary.

    Read the article

  • Magento Design Patterns

    - by JonB
    Magento, IMHO, represents a PHP system that is built on well thought-out coding principles - reuseable design patterns being one of them. In terms of an example of a PHP system, I think it can be considered pretty cutting edge and therefore worth considering from an architectural point of view. As I understand it, there are many design patterns that are available to the OOP developer. Seeing such patterns being put to use in an open-source system such as Magento allows a developer to view examples of such patterns in real use and in situ, rather than in examples that can sometimes be rather achedemic, and even a little misleading. As such, I am wondering what patterns, other than the ones I have listed below, Magento programmers have used when developing for Magento. As a note, I understand that some of these patterns are in place as a consequence of being built on the Zend Framework, MVC / Front Controller being a couple of them, The obvious ones are: Factory: $product = Mage::getModel('catalog/product'); Singleton: $category = Mage::getSingleton('catalog/session'); Registry: $currentCategory = Mage::registry('current_category');

    Read the article

  • Singletons and other design issues

    - by Ahmed Saleh
    I have worked using different languages like C++/Java and currently AS3. Most applications were computer vision, and small 2D computer games. Most companies that I have worked for, they use Singletons in a language like AS3, to retrieve elements or classes in an easy way. Their problem is basically they needs some variables or to call other functions from other classes. In a language like AS3, there is no private constructor, and they write a hacky code to prevent new instances. In Java and C++ I also faced the situation that I need to use other classe's members or to call their functions in different classes. The question is, is there a better or another design, to let other classes interact with each others without using singletons? I feel that composition is the answer, but I need more detailed solutions or design suggestions.

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >