instruction
stringlengths
34
36.1k
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...
What are the generally accepted means of running tests that pass on the dev machine on the build server where they'll consistently fail due to missing dependencies? (In this case, a configuration file that is managed by another completely external application.) My app is reading an INI file containing various key/value...
In my previous question, it was highlight that implementations of C++ such as GCC must store a vtable pointer in every copy of a class for each parent class which has a virtual function. So a class which implements say 5 "interfaces" (i.e. pure abstract classes) must be at least 5 pointers in size before even it's own...
I have a simple project where the controller calls the service, and the service calls the repository in order to get the needed data. Assuming that we have these domain models: // this model has a RepositoryA built for it Class A { public string Name { get; set; } public int B_Id { get; set; } } // this model ha...
I have a service (S) that receives an object of type 's', this service will be called by several classes (maybe 6) and each class has their own object a,b,c, etc. with the information necessary to fill object 's'. There is no big logic when setting the values of 's', just some s.setPhone(a.getPhone()) calls. Would it ...
I have a serious problem with application which i working on. It has a lot of procedural code and now it needs to refactoring now.. The problem: we have two different application in general, but they're use the same "module", concrete functions from this module. It looks like this: (pseudocode) // general application c...
I am looking for the best approach to design the following system : I have a class of object, called Compilers (C, Go..Etc) I have another class of object, called Protocols (HTTP, RPC, WEBSOCKET..Etc) I have another class of object, called Serialization (BINARY, JSON..Etc) Now each compiler has to be matched with the...
Background I have an application which stores a lot of entities in a classical relational database (Microsoft SQL Server) and I use an ORM (Entity Framework) to query data from it. This database has one schema any only a "global view" to this data exists. The data is made available to users via an OData API. For simpl...
Is it possible to create an algorithm that will execute at the same rate and speed on faster and slow computers. What i mean is, i have a year 2000 desktop that can run a certain computational algorithm. a hundred years latter, quantum computers have arrived in their full capacity and i want to run the same algorithm. ...
I have an endpoint "import" that is supposed to accept an entity. This entity can contain several sub-entities with yet again some sub-entities. Since this is an "import" endpoint, some of the entites or sub-entities may exist from previous imports some may not, some are required and some are not. Some have special rul...
Today my manager said: 'Amir, don't mix the business logic with data in database'. I surprisingly shocked! I said 'Where?'. According to wikipedia business logic is: In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data ca...
Myself and my colleague were having a discussion about MVVM and how lists and selected items should be stored in view / viewmodel. I think the viewmodel should only offer up the data and allow the view to interpret it how it likes. It could display it as a list with a selected item or it could show it completely differ...
What are the best ways to unit test code that outputs random sequences satisfying specific conditions, such as Markov chains? Let's be specific. There are two natural things to test: That the initial state returned in each chain follows the user-specified probabilities, such that chain[0] == i with probability p_initi...
A flat state machine has one active state. In a hierarchical state machine (HSM), if the HSM is in a child state, it's also in it's parent state. So, an active state configuration of an HSM consists of multiple states which form a tree. If the HSM doesn't have orthogonal regions, the tree simplifies to a list. Is th...
Some sites, like theater ticket reservations, place a limited-time hold on the item , while the order is being processed. As soon as you select the seat and proceed to pay, Seat is reserved say for 10 minutes. I see here a big risk where a hacker/automated script(bot)/manual user can lock all inventory and does not act...
I'm currently developing a controller for an industrial application which takes data inputs from various sensors and interfaces (ethernet, serial, etc.), does some minimal processing, and adjusts outputs to interfaces and mechanical systems as needed. The device, a B&R X20 automation controller, uses a simple RTOS oper...
Auto-completion :- When we start typing, does system suggest the product from cache or hit the DB every time or hit the DB only when no result found in cache ? Search:- When enter any product, does system straight away hit the DB or tries to fetch it from cache first ? Orders :- I believe here order must be straight a...
I'm trying to write a very high scale IRC logger that can handle like 1k messages per second. My Database of choice is cassandra and maybe later I might look into scylladb. My Question is how do I write the software part to be distributed. How do I best horizontally scale this. The obvious way would be to have multiple...
our startup is working on an integration for various customers. All of the customers are required to provide their data in one unified way = we chose XML files because of legacy compatibility and ease to validate the files with XSD schemas. The scenario should be that the customer provides their XML file which we will ...
I have an interface IMyService in a class library. I have an implementation of this interface MyService in a separate class library. MyService may raise a custom exception CustomException. Should CustomException live in the interface class library, or the implementation class library?