Tag Info

New answers tagged

0

I would approach this by having a top level UserService that doesn't care what type of user it's dealing with. If it gets a request for a user by email, it can look up on the database which type of user is correct and delegate the request to the correct service. This may sound a little inefficient, but used with an appropriate query caching later it's ...


0

I think solution 2 is the better solution. You want to avoid treating connection commands as special cases. That would add complexity to your script engine and/or script language. Your commands should receive a general purpose execution context (or script state). Some psuedo-code could be: interface ICommand { void Execute(IScriptContext context); } ...


2

Returning an Input Steam enables your calculation to be performed on an ongoing basis as data is read from it, potentially even in a separate thread. It is equivalent to a unix command line pipe. If the processing takes a significant time to complete, this will effectively hide that processing time from the user by distributing it (or shunting it off to ...


0

Sequence diagrams are good for specifying the order of message exchanges between principle objects of interest: User, LoginController, ... etc. When an object receives a message, the reception should cause some logic internal to the object (specified by the object's class) to run. The algorithm that describes what that logic does is not documented in the ...


1

You really can't "solicit" those requests. What you have to do is go out and LIVE with those clients, and see how they are ACTUALLY using your product, and see what is ACTUALLY eating them alive, causing them to curse you and your ancestors in languages long forgotten except for the specific purpose of calling down the wrath of gods best left undisturbed. ...


0

You will probably get lots of more feedback as soon as your new product is on-line and people start using it. Especially, when you replace your existing application, so your clients are not able to use the old one any more. So work towards that goal - give your clients a version of the new product at hand with access to the same feature-scope they had in the ...


0

You could use an EventBus. When using a bus system, components in your application can register for events that are fired by other components. This way a monster could fire a MovedEvent ore something that contains the necessary data. There are several implementations in several languages. In java, commonly used one is part of guava: ...


1

In the example you give (mission controller turns monsters blue), you wouldn't need communication between the controller and the monsters. Instead the monsters could look up the "monster color" in a palette (or color table). The mission controller just sets a different value for "monster color" in the palette when the mission changes. Or switch the entire ...


4

As with all program design, if you have two things that need not know about one another (A and B) then the proper design is to have some mediator C that lives above and knows about both: C / \ A B The mediator can then glue the two together via a generic decoupling mechanism (events, messages, delegates, just passing one into the other, etc). For ...


1

There's a risk that the second approach leads to a Fat Controller, which is often considered an antipattern. It's effectively a violation of "clean architecture" (as by Uncle Bob Martin) since your controller is now not only a "delivery mechanism" but also deals with applicative transactions/use cases, orchestrating calls to the repositories and services and ...


1

I actually think this is one of the major advantages to being able to have a class, that implements multiple interfaces, while having one "implementation". I think the problem is with your example, than with the idea. I remember I did similar solution some time back. Basically, I created a behavior, that did some work and it required some work before and ...


1

Imagine a Chinese person who doesn't know English who's trying to read your configuration file. Alternatively, imagine the configuration file is in Arabic (and that you don't known Arabic). Now ask yourself, is this really human readable? Even if the reader does know English, they've still got no idea if "logger.datarate = 100" means 100 characters per ...


2

I say what you have (properties file) is already the best human readable configuration format. :) Here are my arguments: Properties file is just key/value pair. Easily readable by human. Terse syntax, not like xml. Easily nest-able, with '.', like in your example. Flat structure allows easy diffing in a source controlled environment. That last point is ...


1

By the general description given, it sounds as though the concrete types WordBank and WordSorter (might be better called WordFilter) should be separate types both implement from a common interface IWordSource, and/or inherit from a common abstract base class WordSourceBase which does so, rather than having either concrete type inherit from the other (setting ...


1

No, the two concepts are different. A better car analogy would be regarding the engine. Let us assume we have an interface for an engine. It might have properties such as number of cylinders and RPM. You might be able to invoke behavior such as opening and closing the throttle. However, this is just an interface: engine is not an implementation. The Car ...


0

You describe a situation in which the user updates three rows. The first transaction completes after the third click, and all three rows update themselves with the stale data. You need to think about the granularity of your model items. It sounds like you want each row on the UI to represent a single aggregate (transactional boundary). So when an aggregate ...


4

As the null-implementation is supposed to be a drop-in replacement for the full-functional implementation, the null-implementation should fully adhere to the interface that it implements. If the WifiComponent interface specifies that connect() throws an exception if it gets invoked with an unsupported WifiEncryptionType, then that is exactly what your ...


3

Should we use another way for sharing data between these three classes? No, that is not the point of what Fowler is talking about. The usage of a DTO is probably fine (Fowler himself recommends it, especially in a remote scenario). The point is that during refactoring, such a DTO might become a better place for operations which work exclusively on the ...


-2

Patterns are common solutions to common problems. We are always following some patterns, the patterns by GoF address the most recurring ones. That, to have a shared understanding and shared approach known to software engineers. That said, my answer is no, but yes you are always following some pattern of your own. As the GoF rightly puts it- One ...


7

At some point, every project becomes too large and complicated to keep it all in your head. For some this point comes sooner or later than for others and you seem to have hit that point in your project now. The first step now is to start writing that dreaded documentation. Write down what each class is supposed to be doing, which classes work together ...


2

I had a similar problem with my code with global state via singelton. As @Thomas-Junk-s and @SHODAN-s comment suggested i refactored my code to make the static global state non-static through constructor Dependency injection. Example original code public static class Global { public static int getSomeGlobalState() {...} } public class MyClass { ...


0

Yes, it's better not to share state between unit-tests, and have them independent from each other. But it doesn't mean that you can't share code between unit-tests. For example(using NUnit + FluentAssertions + FakeItEasy): [TestFixture] [Category("Unit")] public class when_rolling_back_unit_of_work : UnitOfWorkScenario { [Test] ...


-2

It doesn't seem to me these layers are really separate unless they are different applications entirely. Though the idea of separate classes like BL and DAL etc sounds good, I rather think the UI should only handle UI functions and receive from the BL only strings and numbers in an expected order to be passed into the appropriate controls. The BL can ...


2

First off, there is absolutely nothing about C++ which forces (or even encourages) you to use OOP. This is a common misunderstanding. Other languages lend themselves to OOP much better than C++, and while C++ supports OOP, it supports other paradigms much better. That said, your problem is classic, and lends itself well to the command pattern. It’s worth ...


1

If you need some data created somewhere in another class, you have to pass it. That is not bad style, there is nothing "messy" in it, that is just the way how data is to be used in a program. Ideally you pass it only once in the constructor: MainMenu main_menu(tree); If that tree is needed in lots of places inside the class MainMenu, you store just a ...


0

Why don't you just use RTTI to get a string representation of the class name directly? Yes, it is implementation defined, so you can't depend on it being some exact thing if you are switching compilers. However if you need human readable logging, this is an excellent solution that doesn't involve adding a line of code outside the Logger class itself. ...


0

Moving the data to archive tables will reduce the amount of data in the "live tables", but it won't reduce your overall database size. So if that is your goal, use files, which can be compressed easily if necessary. However, if you want to be able to query your archive data later on, and database size is not really your problem, the archive tables may be ...


2

so, to recap: your shapes have actual names, determined by some outside entity (possibly user input), and aren't always just Circle1 etc. you don't think the shape should be responsible for this property (namedness? nominativity?) Well, assuming you don't use a global logger and the logger itself has a sane interface, you can create a named logger proxy: ...


0

AT commands are generally not designed to be multiplexed over a single channel, so if you have sent multiple requests without waiting for the responses, it is very likely that you will get the responses in the same order as that you sent the requests (although it is better to simply wait for a final response before sending the next request). If it is ...


2

What you'd like to have is a mixin, or a trait, but you can't have it since your language of choice doesn't support it. So you are looking for ways to emulate it. Personally I agree that deriving an object's name shouldn't be its own responsibility. For one, because if your naming convention changes, you have to change your Rect.Name implementation. So now ...


0

You're describing a sort of copy constructor: using one Msg instance to construct another. I would implement it as such, finding another place to put common helper functionality. public class A implements Msg { public A(Msg msg){...} } public class B implements Msg { public B(Msg msg){...} } However, you've been vague about your reasons for doing ...


0

Use archive tables, and use a trigger to archive the record into the archive table. These triggers can be generated programmatically from the table definition. Then you can just delete the records with the cascade option, and know that the archive is being created automatically.


15

General suggestion : DO NOT USE VERSION CONTROL ! (for this kind of problem) Either make it so the application has all features that can be turned on/off using config files. Or make the application modular so each customer gets slightly different modules.


2

Why do you need the mother of all base classes? Isn't that sort of what object is for? Seems to me like you have two problems here. You have a base class that is too general, and you have classes for EmailFrom and EmailTo which are too specific. Your base class should have a name that suggests its purpose. Atom doesn't do that. And EmailFrom and ...


0

I think message queuing is your answer, along with discarding the idea that the user should wait for the processing to complete. When the user uploads the file, queue it to a message "processor" which will do the preliminary analysis on it (basically just decide if it's too big and either divert it to a "splitter" queue or simply put it on the regular ...


1

Speaking purely solid your classes: TrackLead, TrackOpportunity Are already fine grained and therefore should be compliant to 'S' single responsibility. Your class: LeadEventHandler Your lead event handler is like a controller to all these smaller processes, so for it to take in dependencies to the TrackLead and Trackopportunity classes makes it ...


1

Computer power is cheap nowadays. Moreover, you don't know yet where the bottleneck will be. To me, this smells like premature optimization where you worry about performance before even having the load. Perhaps you should just start by making it work, then about scaling it. My 2 cents. The question is also if you want quick processing time or high ...


4

currently there are 2 ways; the type erasure method of java; essentially everything becomes a void* (or a custom type like a struct base{void** functptrs;} and gets casted to and fro as needed, this requires the type to follow a certain interface to let the template figure out if casts are valid at runtime. instantiation creates a new definition of the ...


7

Monomorphization. For every generic (polymorphic) type/function, generate a non-generic (monomorphic) version for every set of type parameters. Given these declarations: struct G<T> { a: T, b: T } fn get_a<T>(g: G<T>) -> T { return g.a; } and this code: x = G<int>(1, 2); y = G<float>(1.0, 2.0); get_a(x); get_a(y); ...


0

Have a look at the Python argparse and cmd modules. If you'd like to make an interactive UI, subclass cmd.Cmd and for each of the commands, you can use argparse to parse the subcommand and options. import readline # for history and autocomplete import cmd class MyShell(cmd.Cmd): def do_add(self, line): "adds various things" print "add ...


0

I believe that the gang of four themselves classify design patterns as a common solution to a commonly occurring problem* So yes, the patterns are relevant when the same type of problem occurs. And this brings us to a problem with the term "Design Pattern". A pattern is something recognizable that occurs repeatedly. So in reality there is not a pattern ...


-4

Slavish adherence to design patterns can be detrimental - patterns are documented solutions to common problems, but they are not instruction manuals. However, just because they are discussed at length and, in some cases, applied outside of effective problem domains doesn't mean they hold no value whatsoever. They are a set of principles - call it a framework ...


0

You need to build an XMPP compatible client or use/modify an existing one. Using the REST API will complicate things. Setup the ejabberd server and follow a normal client/server architecture. It has multiple modules for example for authenticating users through your normal database , saving messages in different databases etc.


4

Arrays aren't the only option for implementing autorelease pools. Anything suitable for a set implementation should be suitable for an autorelease pool, including (single- or double-linked) lists, trees, and hash tables. When picking which data structure to use, consider the timing of the various operations and match that to usage. For an autorelease pool, ...


1

I have three suggestions: Entropy (but in its physical meaning and not in its information science meaning) As wikipedia says, the term entropy is often used to describe the "measure of disorder of a system". I think the situation you described could also be interpreted as the growing disorder of a software system. Architectural drift which describes that ...


1

The usual way is to retain for the calling code, To make it consistent you should do it for all objects that you return. //popFromQueue will remove from the queue and pass the buck to the calling code Foo* pop(FooQueue* q){ Node* foo = q.head; q->head = foo->next; foo->next=null;//make sure new head isn't released; could have also ...


2

Technical debt ? Technical debt is a recent metaphor referring to the eventual consequences of poor system design, software architecture or software development within a codebase. The debt can be thought of as work that needs to be done before a particular job can be considered complete or proper. If the debt is not repaid, then it will keep on ...


0

Your design is slightly distributed, but in very simple, minimal ways. You have functionally decomposed your workload across multiple servers. In 1980, that would have been considered a distributed system. But you do not distribute (aka, partition, shard) any of the individual parts of your workload across multiple servers. There is no substantial parceling ...


1

Session variables are like the old Basic global variables to some degree. The burden is on the user to keep track of them, what's in them, their scope and how they are used; just like in old versions of BASIC. That being said, why would someone totally discount the use of a mechanism that is obviously designed to be an integral and very importaint part of ...


0

All the actual code you've shown doesn't do anything, it just sets up properties, so any answer will involve some guessing. It's not clear to me why having an unconstrained generic type on transition makes sense. Could it take a string type? My guess is that what you are trying to do is let the "extension" class know that the transition has occurred, and ...



Top 50 recent answers are included