instruction
stringlengths
34
36.1k
For example, suppose I have a class to create a button with specific styles common to my app, I can have either Return a new modified object: public class ButtonFactory { public static Button createAppButton(String st, int fontSize) { Button b = new Button(); b.setColor(...); b.setText(...)...
A bit of background. We are in the design phase of an HTTP API, and we are facing the question of how to define complex queries in JSON format. We have a items in our product that have A LOT of fields and properties, and proper filtering is vital for both the users and the interface built on top of the APIs. Currently ...
I recently applied for a position as a software developer. As a part of the recruitment process, I was given an assignment that involves reading data from a file. The thing is that the example file contains extraneous data on purpose. For example, there's a CSV file in which decimal numbers are sometimes written using ...
I am trying to learn how to handle complex context-sensitivity in parsing. Say you have this simple example of code: var x = 10 var y = x + 10 var z = y + 10 var a = z + 10 var b = a + 10 var c = b + 10 If it were just plain JavaScript, the variables would evaluate to this: x == 10 y == 20 z == 30 a == 40 b == 50 c ==...
I'm applying Clean Architecture + DDD (maybe) in my project (web Application + REST API). The good thing I learned from the Clean Architecture is using "Interactors" to show business use cases in my code, which is naturally fit with Command pattern. So that I use Command Patterns in my project. Normally, I named my co...
I am implementing a similar feature like the StackExchange Inbox and I have many considerations about the resource usage. My system has inbox messages, system health notifications and Achievements. On each page request I am querying the DB if there are any notifications from all these three resources (2 tables and one ...
The ideal goal for my system is the ability to perform an arbitrary number of deployments per day to production while making sure each 'push' goes through the full test suite to make sure it holds up to our specifications/user stories. This is a manageable challenge with Integration / Unit tests which usually are rock...
I have a situation that occurs 5 times in my code, and continues to grow. Basically I have the same switch statement structure every time I need to perform an operation that involves my matrix and its type (which is set dynamically at runtime from files and user input). Here is one such example: //QTableWidget m_matri...
I'm currently writing a bigger program in C++ and have reached a point were I get problems with the organization. I wonder if namespaces are a way out. I will try to explain what the program does and show a simplified example of the mess I'm in with it. Part of the program configures so-called Devices. Each Device need...
We have our REST API running on AWS Elastic Beanstalk (NodeJS/Linux), there are some legacy devices that their only way to communicate with the world is uploading a file using FTP. These devices would upload a file to FTP(s)://ftp.example.com, the file is processed generating some output (updates stuff using the API), ...
So basically I am writing a wrapper for a REST API in objective-c so that our customer can easily use them in their iOS development. I am trying to find a good design pattern for this purpose, it seems Singleton Design Pattern is the only choice here. Without a public initializer, it is a shared manager accessible by ...
We know a regular computer basically only knows two states and that we name these states 0 and 1 respectively. This seems arbitrary, we could name them "a" and "b", or even 3 and 4. Is there a reason for the convention of naming them 0 and 1 ?
We have an internal tool where our account management teams can say "whenever we send this type of SMS message, use this text I specify instead of the default text". They would call this 'configuring a custom SMS'. Minimum viable info about how our SMS-sending code works -- the API takes a message name and a user to se...
I have recently started on a project involving a REST API. The API requires authentication with requirements for administrators to be able to view logged in users and to be able to revoke specific login-sessions immediately. The API is consumed primarily by a SPA and a native application. During my search for existing ...
i have a sytem a that include system b and return the result. simple!. concrete example an API, one controller that internally call another class then perform the operation. route --> controller -----> class I would do this a series of unit test for all piece the code then a series of functional test for the contr...
When I recently started doing some 3d graphics, I carefully (tried to be careful, anyway) decided to use the conventional mathematical standard for labelling axes, which was much more convenient for "doing the math" in this pretty math-heavy problem domain. And to try to avoid any confusion, I even included an ascii co...
Let's say in an effort to improve quality, your team agrees on the following policy: all commits to the master branch (direct or via pull request) have to be categorized as either bugfixes or feature changes; never both at the same time. to easily distinguish the two, commit messages have to start with e.g. [bug 123]...
How can I avoid duplicate use of doSomethingCommon() in the following block of code? doSomething(); if (conditionA) { doSomethingSpecificToConditionA(); doSomethingCommon(); } else if (conditionB) { doSomethingSpecificToConditionB(); doSomethingCommon(); } doSomethingElse(); NB: Calculating condition...
Sorry for the unspecific title but I can't find a concise way to state my issue. I am reading the book Clean Architecture, by Robert C. Martin. It has a short chapter about the LSP with a couple examples, but I am unable to understand why the first example does respect the LSP. The principle What is wanted here is som...
Assuming I have resources I restrict access to with a username + password login in my web application and in my REST API. Should I keep different sessions for both meaning that a login via the web UI doesn't grant access to resources accessible via REST and vice-versa? The username and password combinations would be th...
How are operating system animations displayed (concurrency)? E.g. window resizing. I've particularly always wondered about the concurrency aspect of it. Since the OS has to run many many things simultaneously. But animations are often sequential, which means that the frames must be run one after another, and cannot be ...
from my class I include all dependencies in the constructor. to decide which dependencies to pass what rules should I follow? when I decide to use the parameters of a method instead of the constructor?. Concrete example. I have a service that perform a operation on DB. To do this it must have 3 class repositories tha...
For example, in a Student object, in order to avoid primitive obsession, I should change public class Student{ public String name; public int age; } into public class Student{ public Name name; public Age age; } so that name and age have their own object. However, in database, I usually stores Name an...
I'm part of a development organization which has traditionally been using Scrum principles. We have 3-week sprints, at the end of which we produce a software artefact which our customers install on premise, and at their own discretion. Most customers have chosen to skip every odd sprint, and thus only install every 6 w...
A class with a slow initialization used to process a request leads to long response times. But the actual method used is quite fast. Should the class be static, I guess it would need to process a request at a time. So, what would be the best way of combating the long initialization time while not bottlenecking the requ...
This was just a question I was wondering about in terms of best practice. I am writing a small C++ program that uses an interface to implement a function. In the class that uses the interface (i.e. inherits from the interface class), is it bad practice for me to use member variables so I don't have to keep re-declaring...
Currently, my aggregates and value objects have protected constructors and some of them are being created by static factory methods inside the aggregate with descriptive names. It creates a nice DSL and pretty encapsulated model but makes the unit testing painful (if the domain model creation fails, the service/command...
We have a medium sized ecommerce website which is entirely custom built in using Java and MySQL database on AWS infrastructure. Over a period of past several years, our orders volume has grown substantially high and so the size of our database. From past couple of months we are facing a problem of slow CRM (Admin appli...
The question is related to the resolution of the this operator in Javascript classes. NodeJS now supports ES6 classes. The problem faced during this is that when a new instance of the class is created and assigned to a variable everything works fine, but if you assign a particular class method to a variable, the scope ...
I started working as a software engineer with a startup about one and a half year ago. Everyone here cares about this project and works hard. but I have been having an issue here for some time. People here have "lack of discipline" when it comes to development tasks. They ask for one functionality, I ask a thousand qu...
I have done a lot of reading about Event Sourcing in my spare time recently. I understand that it is for situations (Bounded Contexts?) where the business is interested in how an entity arrived in its current state. The classic example is a bank, which would not store your current balance, but instead a collection of ...
How do I ensure consistency between two separate systems which store and maintain the same set of data, when the method of communication between them is REST APIs and webhooks? Is it possible? I find myself coming across this problem when working with APIs like MailChimp or eBay, where the third party system is acting ...
I am maintaining an application that I refactored using the MVP pattern. I use the passive view pattern meaning my view is as dumb as possible only forwarding its events via its interface to my presenter. Right now my presenter got relatively big. Right now I'd like to extract some logic out of it. But that way I would...
Let's say I have some class, and within instances of that class I want to be able to output certain data to various file types e.g. CSV, SQL, PDF, etc. The simplest way is just a series of if statements, but that is generally a closed system. Anybody who wants to extend the code has to have control of the class and ...
I'm dealing with code that renders HTML pages. I'm cleaning up an old, messy PHP code base. Let's say I have a template that loops through a long list of rows in a database. I can load my data into an array and pass that array to the template in order to separate the view from the other logic, or I can pass in the PDOS...
In a client-server architecture, what technique is used to efficiently update ordered list of items without actually sending the entire list? Note that multiple clients will be updating the order of the list simultaneously and the server will decide the correct order. EDIT: For more clarity. Say example I have a real-t...
can base class contain protected methods that are not to be used by all descendant classes? I have this situation: EntityA: has some methods that handle activities EntityB: has some methods that handle products EntityC: has methods that handle both activities and products I use C#, so multiple inheritance is not poss...
I'm developing some test web-project for my self to learn DDD and good architectural practice at all. So application, basically, is a simple photo manager. I'm developing 3-tier architecture and for now I have: DAL: EF database first UserRepository PhotoRespoitory UnitOfWork BLL UserService: user registration, aut...
I'm reading a lot about microservices but one thing remains a bit unclear to me. Let's say in my organization, I have 2 abilities: Extract street names from one or more blocks of text Given a context of a website, understand what pages in it will most likely contain street names (a.k.a "important page") according to s...
I like using the Builder/Director pattern to build complex objects. It works really well. The only restrictions (maybe it is not really a restrictions) I see is that all of the parameters for the construction of an object need be present before calling the builder. I have now come to a situation where I need to build ...
I am writing some data collection software (in python) that will transmit data to the cloud. I am including a timestamp (using the standard datetime module included with python) in the data record so that the time is documented in the cloud datastore. It will run on an embedded linux device. I am between a few architec...
From what I've read (other questions on the site, etc...) the vast majority of desktop systems have little-endian architectures, and Windows doesn't even support big-endian. Now I'm wondering if it's even worth the extra effort to deal with endianness for the small number of big-endian desktop systems (if there even ar...
Should a Scrum team estimate irregular, planned events, such as an overview/demo to new users and potential customers? Our team is pretty small, so the effort to prepare for and conduct these events falls on us (primarily the Product Owner, Test Lead, and Scrum Master). We've even had our entire team there for parts of...
My manager wants us to complete a checklist for a Definition of Done, where the checklist items are short. What is a good way to phrase "code is clear" that might better imply that the code is understandable by a reasonable software engineer, well-organized and appropriately commented and documented? (If I say that exp...
The GO programming language has objects but no inheritance. It also has generics for the built-in types Array and Map. Is there a programming language with objects but no inheritance and with generics (i.e. parameterized types) for all user created types?
I'm making a library for other developers to use and it's for communicating with a 3rd party web service. I read the issue that come up around HttpClient and I would like to handle this properly, so that the library doesn't become a burden. I thought I would make a base ServiceClient that would have 3 ways to construct...
Sometimes I find it useful to have loops that do an action at the beginning and/or the end of a while loop. The best way I can think of for representing this in C++ would be: if(condition) { // Pre-loop actions. while(condition) { // Loop actions } // Post-loop actions. } Or with a goto optimiz...
I have a need to implement a special logical operations algorithm. The task has been assigned to store the logical conditions in a database and have C# code read the information and select the correct result. Here is the scenario: This company uses what they call a config code for all their products. The configuratio...
My development environment specifically is .NET and I'm writing a DLL to be compiled and referenced in other .NET programs we'll be writing going forward. My question is: In that DLL, what is the best practice for error handling? If you have a function doSomething(value) and it fails, do you throw an exception? Or do y...
I'm sure this is not an uncommon theme. We have two scrum teams that are doing an okay job of estimating user stories using story points (the current team constellations are only about 8 months old, although the team members have several years of scrum experience). But it's hard for the business part of the company to ...
Are there any patterns that address how to have and application load and run user defined code at run-time? I am looking into developing a C# library that the users of a Test Executive application (app that interacts with HW to test mobile devices in development) can leverage to define test code (currently the tests ar...
Is it technically correct to call a paid API, e.g. APIs provided by TimeAndDate.com, a SaaS? The reason of asking is that I was having a discussion with someone who was of the view that we can't as for a SaaS there should be a software which end-users interact with and I was of the opinion that 'Software' is an umbrell...
For example, suppose my app have some localized text, my question is , should the key contain actual context of text: { "WELCOME_TO_USE_THIS_APP":{ "en":"Welcome to use this app,...", "es":"Bienvenido a usar esta aplicación, ..." } } or the meta information about the text { "WELCOME_MESSAGE":{ ...
Let’s say I have an event driven microservice system - a microservice cluster - that takes orders and works with them. Orders are placed by an external neighbor system that is working synchronously via a REST endpoint provided by one of my microservices. This service is acting as a facade to keep all the synchronous st...
I'm developing a level editor in Java. I'm designing its code in MVC. From what I've learned: controllers can have a direct reference (fields) to views and models. Views can have direct reference to models but shouldn't have to controllers (they can interact controllers via design patterns such as observers) and models...
As SCRUM teams are self-organized they are free to choose how to implement tasks. However, isn't there a risk that teams could end up deciding to do for instance full re-writes (instead of constant refactoring) every few years just because there is a new fancy framework out there that does things slightly more efficie...
In the MVC pattern, should model and view be very concrete and tailored to the represented component? Or should they be as generic as possible so that they can easily be reused? Specific case My data is a list of recorded frames. Each frame can consist of multiple data blobs, for example, an image and some meta data: ...
I'm not a software developer at all, but wondering if this would be a relatively simple project for creating an android shortcut. My parents like doing the guardian quick crossword: https://www.theguardian.com/crosswords/quick/, I was thinking as a project with some practical purpose would to be have an app where it wo...
Due to the Global Interpreter Lock, multithreading in Python does not affect parallelism. This limitation is avoided in the multiprocessing library by spawning new processes instead. But threading does improve responsiveness in certain (IO-bound) situations. (from this answer on SO). My situation is as follows. A Pytho...
public Path createPath(String name){ return Files.createFile( Paths.get( name ) ); } In createPath(String name), the java.nio.file.Files throws a java.io.IOException. This is however to be used by a larger library. And I mean huge. If I just add the exception to the method signature, that would mean that the large...
Does anyone have suggestions/recommendations/guidance they can offer on when to use a message broker like RabbitMQ/Kafka vs. an iPaaS solution like Mulesoft/Jitterbit/Dell Boomi/Workato? Can they coexist peacefully? Or should one of the two options be selected as the defacto integration middleware? I have the beginni...
I'm currently trying to figure out how to solve following problem: I have a model called Post that has, among other attributes, link_1_text, link_1_url, link_2_text and link_2_url for users to add links to their posts and label them like: 'Find us here' / 'maps.google.com/something' 'Our Facebook' / 'facebook.com/exam...
I have run across a bunch of code where they are essentially doing void CreateFoo(string foo_param_1, int foo_param_2, vector<Foo> *foo_storage) { Foo new_foo = FooFactory(); new_foo.set_param_1(foo_param_1); new_foo.set_param_2(foo_param_2); foo_storage->push_back(new_foo); } To me this seems like a h...
I'm in the midst of a rather large project which involves decomposing a very old and large ColdFusion legacy application and creating some .NET services in it's place. Due to this, there are some requirements I'm not a huge fan of that it needs to support as we transition to this new backend. One of these requirements ...
Is it correct for the user(actor) in sequence diagram to receive a message from object while<< UI>> is exist in the diagram for example user will request to edit some data ..so the request will be sent from user to the UI which will pass it to the object that contain the data.. for example if I want to send reply to u...
When define a locale text map, I can use: 1.locale key first { "en":{ "WELCOME_TO_USE_THIS_APP":"Welcome to use this app,...", "SOME_OTHER_TEXT":"fsdfsf..." }, "es":{ "WELCOME_TO_USE_THIS_APP":"Bienvenido a usar esta aplicación, ...", "SOME_OTHER_TEXT":"fkdjsklfs..." } } 2.text...
For example, to store whether sound is on, I have a boolean originally named "isSoundOn": private boolean isSoundOn=true; however, the default value of boolean is false, but I want my application to turn on the sound at start. My question is, should I change the name of isSoundOn into isMute, so that it becomes "false...
I have a bunch of microservices that are only accessible externally via an API Gateway. My API Gateway is set up as an OAuth Resource and validates the token (Checks signature etc.) before passing the request downstream to one or more microservices. Whilst my microservices need the token in order to verify scopes and c...
Let's say I have an Object Structure like this that I import data into from a source: Reporting: Body: ReportingEntity: DocSpec Reports[]: ConstEntities[] DocSpec AdditionalInfo[] DocSpec MessageSpec Whenever I import the data I have to check for changes in any of the objects a...
Suppose I have a library, that basically works as a facade to some cloud service (e.g. JavaScript API that wraps around network calls to some RESTfull service). And once that service introduces a backward-incompatible change. There are two possible scenarios I can think of, and I'm not really sure how to handle both t...
A lot of code that's designed to convert or parse some data of type Foo into a Bar is written with the assumption that one wouldn't intentionally pass it invalid inputs. As such, it assumes that everything is correct and throws exceptions if it later realizes that something is wrong. This is typically an appropriate th...
I started to develop web applications not so long ago, and therefore there are a lot of unknown things in this field for me. My question concerns web development using the Java language. Assume that we need to develop a client-server application, where the client is a browser. As far as I know, there are at least two w...
This is my first post on the Software Engineering Stack Exchange so let me know if something is wrong with it. I'm looking into the serverless offerings of Amazon to try to figure out if that is the way to go for a few new projects I have in mind. I'm particularly interested in an event-sourced, CQRS model, as I find t...
For example, to convert between g and kg, I have a constant 1000: public static final float G_TO_KG=1000; . . . this.result = someResult*1000; I found G_TO_KG always bind to operator '*'. So my question is, is it better to define a static method: public static float gToKg(result){ return result*1000; } So that I ...
So I have a service which is injected in my controller via dependency injection. I can either use it in the controller multiple times to convert a value when assigning to a particular property in a ViewModel. Or I could pass an instance of the service to the ViewModel in the constructor and use it in the the setter of ...
For example, if 2 classes depend on each other, it is a kind of circular dependency and should be avoided. How about methods? for example, if I have 2 methods which call each other: public void methodA(){ //some other code if(something){ methodB(); } . . . //some other code } public...
I recently did some statistics on the estimates of our two scrum teams. These graphs plot "original estimate" against "actual time spent" (note that logging time spent is much less objectionable, in a scrum sense, than using actual-time units for planning). Estimation history (logarithmic scale) Estimation history (li...
Sometimes our developers push -simple to find- mistakes to our repos, like a missing ";" a "console.log" that is not suppose to be in the main branch, or an invalid json file. With Github you can add webhooks when there is a push event, and with that I can create scripts (on our servers) that download the modified/adde...
Let's us say I have a package which contains different types of TV structs. Now, based on the parameters passed I would like to return a specific TV type. How is it possible to return the specific type without using the interface type TV in the return type. Another example, let us say I want to implement different kind...
Recently I've been reading into topic of test driven development and decided to give it a go with a sensor driver I need. Sensor uses SPI interface and I will implement this driver on STM32F415 processor with help of CubeMX for project generation. After generating project, I have access to HAL SPI functions such as thi...
I'm comparing two APIs to generate a method in C# and want to measure how "complex" the code to use them is. Consider: API A: MethodDeclaration(PredefinedType(Token(IntKeyword)), "CompareTo") .AddModifiers(Token(PublicKeyword)) .AddParameterListParameters( Parameter(Identifier("other")).WithType(Identif...
Have a project setup in VSTS with the scrum template and one of my team has added several work items. We have several different teams setup and Ive added separate sets of iterations, 1 set per team. My questions as Im going through the docs are What is the difference between "work items" and "backlogs" If I see the...
I am starting a new DDD architecture and I have a dilemma with Domain Events and the way they're retrieved and stored in an EventStore database. First of all, should the EventStore live in the Domain layer or in the application layer? At the moment it makes more sense to me to have it in the application layer since the...
Because of some essential C++ libraries, I have to mix Objective-C and C++ in my code. But the problem is that the callback between C and Objective-C is extremely hard to design and manipulate, so I found NSNotification to the rescue. Many functions in my C++ library are asynchronously running and I found NSNotificatio...
Background: I am writing an application for a small embedded device. There is a static list of strings: currently about 500 strings and string length is 12 characters on average. The list might increase in the future. When the application starts running, the list of strings will be parsed once. No more additions, delet...
I frequently have relatively contained components (services) that do specialized things. These are also almost always immutable to make changing them less error prone. Note the below is within one relatively big project, not small services in separate processes, but that doesn't change much. Take this system as an exam...
In old-style await'less NodeJS, when you call a function that had an asynchronous aspect, you'd pass in the well-known callback which gets called when the asynchronous portion is done. This didn't pollute the return value of the function whereas the function can still return something meaningful to the caller synchro...
I'm trying to understand this and having a hard time. I usually use Ubuntu server, with Apache2, and this time I am not. So I'm a bit out of my element. I'm also a software developer and I don't do much SysAdmin/Devops server stuff. I figured I would post this here, and I'm hoping this is the right place to do it. ====...
So, I am a beginner level Java guy and I was following the java 2D game development tutorial on YouTube by CodeNMore. in the States video (https://www.youtube.com/watch?v=871zoXsYrbI&index=11&list=PLah6faXAgguMnTBs3JnEJY0shAc18XYQZ), he had this line of code: if(State.getState() != null) State.getState().render(g)...
We are coding a small game and have a Player class. This Player class has certain properties which you would persist in a database like Id, Level, Health. We would like a Player to be able to kill another Player. For this we need a method which reduces the Health of the Player. To accomplish this do we: Create a metho...
We built an application that has a list of fixed intranet URLs and crawls these periodically, transforms the data, stores it in a database. We have the requirement that the application has some kind of automatic failover mechanism. So we ordered two servers in two different data centres. Now: We can't let the two appli...
There are a lot of questions and answers about what a/the model is. Particularly when discussing where business logic belongs and the MVC pattern. There seem to be two concepts that need to be severed. I hope a question to this specific clarification has value. The options are: A simple data carrier. No thinking excep...
so I have this android app at work, if I understand it right the DAO/services/UI layers is to "decouple" the UI from the database. I have 2 problems with that : 1/ Decoupling Like this if things changes in the DAO layer/database schema I just have to touch the service layer and the UI stays untouched. Allright, why? I ...
Let me start by setting up the context briefly. In our organization (a Big Data company), there are many different systems, including Web sites, workers (system listening to queues and/or topics), scheduled processes (processes triggered ), and so on written if different technologies such as .Net, Java, Python, etc. As...
I have googled and read few articles about the TDD for UI. I am not very much clear about how to start the implementation of the Graphics Application using Test Driven Development or how to write unit test cases for graphics application. The main features of the application is rendering the UI based on the user inputs....
I know that one of the most important features of hashing algorithms, is that minor changes in the input should reflect great change in the hash itself (the avalanche effect), but I'm currently searching for a solution that doesn't implement this. I've read this answer on the cryptography stackexchange, but it doesn't ...
I've got a resource as follows where state is a enum: { id: 123, industry: { id: 245, name: "Farming" }, "scheduleDate": "2018-01-01", "state": "Requested|Approved|Standardized|Canceled|Done" } The only properties that can change are scheduledDate and state and I'm not sure what's the correct way to ...
I am writing a recursive descent parser. Let ParseContext specifies the context for parsing. Pseudocode: class ParseContext { Logger logger; // logger for error/warning messages Locale locale; // locale for error/warning messages } Classes derived from ParseContext may specify additional parse options, such as...
I am currently working on an implementation that based on a set of user configurations should output a final decision. The multiple configurations are evaluated several times at different stages of the execution. Example: Let's say I'm building a system that plans the perfect vacation for a user. The User object is the...
We know that composition is a synonym of loose coupling. From here I read coupling becomes stronger between the classes A and B when: A has an attribute that refers to (is of type) B. To implement a composition between 2 classes, we declare an attribute of one of them of a type of the other one as explained here...