Quantcast
Channel: User Filip Milovanović - Software Engineering Stack Exchange
Browsing latest articles
Browse All 59 View Live

Answer by Filip Milovanović for What should I write before the tests in Clean...

You can have your presenter built bit-by-bit as you're adding tests.But more importantly, in principle, you don't need to write any of these extraneous implementations beforehand, and you don't need to...

View Article



Answer by Filip Milovanović for Calling helper functions in a Python...

You didn't provide a lot of detail, but this usually happens because you're trying to do too much in one class.Now, if you don't want to clutter your class with helper functions, you could, as others...

View Article

Answer by Filip Milovanović for Where should interfaces be used?

I don't think there's really a simple answer that can do a substantially better job than the statements of the principles and practices that you've already encountered.I know you're aware of this on...

View Article

Image may be NSFW.
Clik here to view.

Answer by Filip Milovanović for Can the presenter talk to to the controller?

So, there are a couple of things to understand about this image - the primary purpose of this diagram is to depict how to organize dependencies between components that are in different layers. So, the...

View Article

Answer by Filip Milovanović for UnsupportedOperationException vs Interface...

"However, since not every card is going to have the correspondingabilities, I realised I would have to throw something along the linesof UnsupportedOperationException"You're thinking about it in the...

View Article


Answer by Filip Milovanović for Are repositories async?

Today, you'd typically make it async. There was a time when mainstream languages and their standard libraries didn't have async/await or things like promises and futures, so you had to do things with...

View Article

Answer by Filip Milovanović for Difference between Resolvers and Controllers?

Disclaimer: this is based on what I've read, not on direct personal experience with GraphQL.It looks like the term "resolver" is associated with GraphQL (at least in the context of your question),...

View Article

Answer by Filip Milovanović for The notion of configurable strategies

"As you can see above, each Strategy is optionally configurable through its constructor."This is perfectly fine/normal, and is in fact one of the cornerstones that makes polymorphic types flexible: you...

View Article


Answer by Filip Milovanović for Should an optional boolean function argument...

I agree that you should go with what makes more sense semantically, but I also find that, when the boolean argument is optional, the thing that fairly often makes more sense when omitting it is for it...

View Article


Image may be NSFW.
Clik here to view.

Answer by Filip Milovanović for Is it okay for an Interface Adapter /...

The More General Part of the AnswerI'm going to answer the question you stated in your closing line, but there's a caveat - see below.Is this okay? Considering the Interface-Adapter and Gateway are...

View Article

Answer by Filip Milovanović for Which Clean Architecture Areas do Gateways...

Without seeing more code than what you provided in your Typescript example, it's impossible to be 100% certain, but I'd wager that the following is roughly correct (if not, just mentally shift it by...

View Article

Image may be NSFW.
Clik here to view.

Answer by Filip Milovanović for Tests of 1-Dependency VS Tests of 0-Dependency

"why are "unit tests" considered so important when they don't reallytest your application"Perhaps an analogy will help; an isolated unit test is like SpaceX engineers testing one of their Raptor...

View Article

Answer by Filip Milovanović for How can I achieve polymorphism if MVC logic...

Context: From some of your comments, it seems like you're dealing with what's basically a desktop application running on JavaScript, so this is mostly written in that light (that is, the scenario is...

View Article


Answer by Filip Milovanović for What is the relationship between variance,...

"In a general sense, covariance is achieved when the direction ofassignment compatibility is preserved. Contravariance is achieved whenthe direction of assignment compatibility is reversed."You omitted...

View Article

Answer by Filip Milovanović for Liskov Substitution Principle Edge Case

A class doesn't violate LSP by merely having an extra method. The behaviors that LSP talks about are not methods, but rules and relationsips and constraints that the class is meant to follow/enforce as...

View Article


Answer by Filip Milovanović for In Clean Architecture, how do we name...

Here are a couple of guidelines:1. Don't use the UseCase suffix. UseCase, within Clean Architecture, is more of a role that a piece of code has within the system. While it might be helpful at first to...

View Article

Image may be NSFW.
Clik here to view.

Answer by Filip Milovanović for Is this really loosely coupled?

My guess is that the idea here is for client code to use service-specific interfaces (like your IProductService), that decouple them from the service implementations.If so, the intended dependency...

View Article


Answer by Filip Milovanović for Unit Testing - should / how should I write...

Regarding call verification - test doubles/mocks that check if a method was called (at all, or with certain parameters, etc.) are called Spies. See this article on different kinds of test doubles...

View Article

Answer by Filip Milovanović for ECMAScript Primitives: Immutability vs Value...

"You could just say that primitives are stored directly in a variable.Such a value could never take any effect on other variables"That's not true. This is where the metaphor that describes a variable...

View Article

Answer by Filip Milovanović for Should edge cases be part of one test, or...

I'll give you an overview of what tests should look like, but note that it might not be easy to achieve this without having a certain level of experience, and that it may be better to think of this as...

View Article

Answer by Filip Milovanović for What is the responsibility of a typed...

Ideally, the models (data structures or proper objects) exposed by the application layer interface, as well as the methods on the interface, would not be defined by the external API specification....

View Article


Answer by Filip Milovanović for How do you decompose big object for testing?

What you want to do is test the contract between the two objects.One set of unit tests checks the behavior of the sub-object in isolation. This set of tests is essentially a representation of various...

View Article


Answer by Filip Milovanović for Message Dispatching: If, Visitor, or...

I should be able to add new types of messages AND/OR new types of handlers without affecting the existing messages or handlers (i.e., loose coupling).So, what you might be running into here is known in...

View Article

Answer by Filip Milovanović for Clean Arch: Where to put HTTP request inputs...

From what i understand of the clean arch., I/Os from the "outside" should be handled by the presentation layer.. but because the presenter has to be called after the service it has no chances to take...

View Article

Answer by Filip Milovanović for Visitor Pattern: what's the point of the...

But I really don't see the point of that accept call. If you've got the visitor and the objects to be visited, why not just pass these objects directly to the visitor and avoid the...

View Article


Answer by Filip Milovanović for Does the Visitor Pattern necessitate...

I have a class hierarchy of elements (more static) with differentoperations on them in another class hierarchy (more flexible). ... Idecided to use the Double Dispatch technique:elem.do(operationObj) {...

View Article

Answer by Filip Milovanović for Why just "interface segregation principle"...

These principles are largely language agnostic, so, the word "interface" doesn't mean a Java interface type (although, that's often what it will end up being in Java). The term is used in its more...

View Article

Answer by Filip Milovanović for Will I lose confidence of my code working in...

Now that I've read your question a bit more thoroughly, I think the problem lies in you being unclear about what the public API of the IMagic type is, and how the return value figures in it. (It is not...

View Article

Answer by Filip Milovanović for What's the difference between Observer...

This is the Observer pattern - it's the exact same thing.I have used some kind of "listeners" where I have an interface implemented by classes that need to be notified of some event (e.g.:...

View Article



Answer by Filip Milovanović for What is the right understanding for cohesion...

Firstly, am I wrong in assuming that just asking about cohesion and coupling with regards to this code is enough to motivate this refactoring, or should I be using other principles, asking other...

View Article

Comment by Filip Milovanović on How do unit tests facilitate refactoring...

"Unit tests are inherently tied to the way code is implemented." - no, but that's the crux of the issue: how most people write tests makes them tied to the implementation. Suppose you're testing a...

View Article

Comment by Filip Milovanović on Are there any true differences between XAML...

XML was all the rage back when they developed WPF (a desktop application framework), and my guess is that they wanted to base their UI markup language on XML and utilize existing XML-parsing and schema...

View Article

Comment by Filip Milovanović on How do we call the approach to unit test...

I'm not sure that there is a specific name for this.

View Article


Comment by Filip Milovanović on How do we call the approach to unit test...

I won't downvote, but this is not the PageObject pattern (which is a similar idea, but it's at a slightly lower lever compared to what the OP is asking about, and the motivation is different). Also,...

View Article

Comment by Filip Milovanović on How do we call the approach to unit test...

"This is where you apply similar techniques to your test data" - I just wanted to add (or clarify), it's not necessarily plain data classes (though that's probably very common), Object Mother could...

View Article

Comment by Filip Milovanović on How to manage long dependency injection list...

This question is very unclear - it would help if you provided some more context. From what I was able to gather, you're saying that the input data (the example you provided) is created by users through...

View Article


Comment by Filip Milovanović on Is it a good idea to return a Builder from a...

A builder is already a kind of a factory (a factory doesn't have to be a static class). So, I wouldn't go through a static function, unless your team absolutely insists on that for consistency with...

View Article


Comment by Filip Milovanović on Clean architecture and components

Martin's view on how you deploy the application (single executable, bunch of local components, distributed components/services) is that this is, in a way, an orthogonal concern with respect to...

View Article

Comment by Filip Milovanović on DDD - Managing Relationships between Domain...

"there is a relationship between entities across aggregates, which should not happen" - that's not quite right. What DDD enforces is going through the aggregate root; it says that you shouldn't be able...

View Article

Comment by Filip Milovanović on In "I don’t want my users knowing that I’m...

Don't extrapolate too much from the tone. The author is just talking about what role he wants the class/interface to play in the design, and what information he wants to communicate, vs what he...

View Article
Browsing latest articles
Browse All 59 View Live




Latest Images