instruction
stringlengths
34
36.1k
I have a situation where I am running mostly end-to-end tests on my framework: I start of with simple fixtures (which are CSV-files). These are imported by my application (which I consider to be a black box in my situation). When the importing is complete I check with repository classes if they return what I expect t...
The title might be a bit vague, so let me explain. Let's assume we have a function that does something (changes state of the program), for example a function that creates a file. That function returns True if the file is created and False if the file isn't created. Now, we want to use that function in a conditional, fo...
My eyes are destroyed. I am using a screen reader. We are using git as our version control system on our project. We host our own server and use ssh to access it. We put each module under separate branches, then merge them all to a branch called dev for testing. Then when we determined that everything is stable, we mer...
I'm a front-end developer, working on a large enterprise application. The application has a 'Dashboard' view, consisting of tiles, each of which display different types of data, or different interpretations of the same data (e.g graphs, charts, maps, etc). There are filters which can narrow the data down and allow the ...
I was learning about design patterns and i came across a line where a domain object has to update it's view using observer design pattern. In the book , Applying UML and design pattern, It says Let the gui object simply apear as an object which implement Propertychangelistener. So my question is that is it a GUI that i...
I have a business requirement that any account viewed needs to be logged. I'm trying to figure out where this requirement should be in my code. This is a query type event and doesn't require going through the entity itself like most of my domain events. Should I encapsulate all of my repositories into domain services t...
I am separating one of my method extension classes (i.e., StringExtensions) into regions, as has become confusing and it's difficult to see the wood for the trees. I have grouped the methods into four regions, as follows: Identification: Usually associated with the verb to be, e.g., Is, Has, etc., and returns a Boolean...
I am implementing a DelegateCommand, and when I was about to implement the constructor(s), I came up with the following two design choices: 1: Having multiple overloaded constructors public DelegateCommand(Action<T> execute) : this(execute, null) { } public DelegateCommand(Action<T> execute, Func<T, bool> canExecute) ...
You have a class X and you write some unit tests that verify behaviour X1. There's also class A which takes X as a dependency. When you write unit tests for A, you mock X. In other words, while unit testing A, you set (postulate) the behaviour of X's mock to be X1. Time goes by, people do use your system, needs change,...
I'm working on a service that forwards/unifies our API calls to external platforms/services. For example, let's say that I don't want to handle all possible actions (create post, retrieve post, edit post, list posts) for Facebook, Twitter, LinkedIn, Google+ at each user-facing service. So the user-facing services call...
I'm a participant of the Apple Developer Program and have been downloading and testing beta versions of iOS for a number of years now. When updating to a new iOS version I sometimes notice that a number of popular applications require updates via the App Store. This indicates to me that the developers behind these app...
For a web application I was asked to design a backup strategy. At the moment there are hourly full backups (database and files). In light of the GDPR, and because it's just the way it should work, recent changes happening between two backups, should be restored as well. For example: 14:00 Create backup 14:05 John dele...
I have a "difficult" problem that i am not sure how should i approach it. Basically i have a mobile app, that has a server side (in Go) and the appropriate base (PSSQL). User can register via the standard procedures, via email, google, twitter etc and create a profile, and after that "use" the app(This is app B). Now i...
I'm new to server development, and I'm trying to figure out where the division of responsibilities is for Data intensive tasks, I'm using Node.js. As an example say I'm making a Single Page Application: The Client renders a map with population per area The Server handles requests for the population data However, assu...
I'm creating a domain service for each of my aggregate roots in order to facilitate some logic that won't be able to fit inside the entity themselves. I would rather not implement a factory and service for each aggregate root. Also, I do not want to expose my repositories to application services directly. My repositori...
As an intermediate stage hard-coding is accepted by Google in their Tour of Heroes Angular tutorial but the benefit cannot surely only be for novices. Do people not understand that hard-coding as an intermediate step allows an additional stage of testing to be undertaken on highly scalable systems in a manner that remo...
I was trying to find if there is some kind of reference about what type of informations are important to be passed on the HTTP Header. I understand that some information seems natural to be there, like the Authorization, Content-Type, Accept, and so on. Some articles explains that the HTTP Header are used to send opti...
Agile question: does agile believe in getting things up and running the “quick and dirty way” - or does agile prefer building solidly from the ground up? Or is this not a methodology question, and more a question that you evaluate case by case? I’m technically “remaking” the foundation of system, after I already built...
I was reading the 12-factor app while thinking about the design of a personal project. I like a lot of what I read, but the following paragraph confused me: In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments”, but instead a...
I have the following problem. I have a react application that needs to load a grid of individual small, fixed size images, up to a few hundreds (think a 20x20 grid where each cell is a 100x100 image). There is also a combobox where I can choose different selection options, and each option will need to display a differe...
long-time reader, first-time asker here. I have a service which writes data to a database in batches. It contains a buffer which is being watched by a separate thread. Whenever the buffer reaches a certain size or a certain period of time has elapsed since the last write, the thread writes the data to the DB. In Java, ...
I'm developing a chat module for my employer, and one of the requirements is that I "get enough backlog to fill the screen" when opening the room, instead of always limiting it to a specific number for each query (such as I'm doing right now) I don't know if I should be dynamically changing the number to query on the c...
I have gone down the rabbit hole that is abstracting away a working game engine in OpenGL and C++. Before reaching the other side I'd like to ask about my current design, which is - the more I look at it - eventually in need of a major revision. I have separated windows, input and frame buffers from the concerns, but r...
We have one table meta where there is key and value so each of the row represents one component or service and then we have api system which manages the metas database. And it was going pretty well when we had 10 rows = 10 properties now it grew to be 30 and its so annoying i am using php and lets say it looks like Cl...
I'm working on Finite Element code in MATLAB, and the number of constants (for instance user input defining the geometry, physics, numerical solution scheme) is substantial. Currently, I've been passing variables between subroutines using global statements, but these offer no indication what the variables are or what t...
Only in the past 3 years I got in contact with enterprise architecture and its terminology. The more I read about it the more I was confused about the term "service" that appears to have a multitude of meanings. For example in the context of Domain-Driven Design (DDD) there are domain services, application services and...
While working on an application, I am facing an issue. And I am not sure how to solve this. For explanation I have managed to come up with a simple example below: Consider a Grocery Store application. It has a finite number(which means the items wont change often) of items. Each item is different than other a...
So we have a microservices architecture. Quite often we release features that require changes in several repos simultaneously. What approaches are best for handling this? Ex. Pull Request 1 from Service A dependends on Pull Request 2 from Service B. How do we make sure Pull Requests are integrated and merged into the s...
I'm doing an assignment in my Linux class and my teacher is a fill-in so he's just going with what is given to him. In the assignment it says to write a script using an Implicit loop to create file systems on partitions (they are the arguments) and use an Explicit loop to create a mount point under /mnt. No where in...
I'm refactoring a project I did for my work and I'm trying to apply the SOLID principles to make the architecture cleaner. I've run into an issue with the Dependency Inversion Principle that I can't seem to solve. The Dependency Inversion Principle states that higher level modules shouldn't depend on lower level ones, ...
I have recently started working on a project where we have a workflow engine which has flexibility to add dynamic states and corresponding actions for each state and all these are stored in database. For example: Workflow Name: Make breakfast Workflow ID : 143 Workflow States state 1 : Turn on stove state Id 1121 ...
I am making this independent drone control system that a user can start and stop. When the program is started, the connected drone takes off, hovers, and turns to face the other side. At first I though of a use case diagram like this: The issue with this is that it seems as if the developer can execute "Take off" etc....
Lets say i'm a new guy coming to the project, how do I clearly determine if there is a debt on the project? What will show it to me? Lets say a certain amount of TD exists at any project. So the next question is: how to measure it? How to quantify the amount of technical debt? Without resorting to metrics (like code co...
I got the following entity and VM: public class Student { public int ID {get;set;} public string FirstName {get;set;} ... } public class StudentVM { public int ID {get;set;} public string FirstName {get;set;} .. } Now, which of the following is a better way to convert one to another (a...
I understand that Annotations aren't directly used in compiled Java programs outside of access through the reflection API or some other means. Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they an...
I am currently working on a web application as a learning project, which has a NodeJS backend and uses a MongoDB database; however, I believe my question is not specific to the technologies I am using. When creating a RESTful API, I can appreciate that you should always respond to the client with the appropriate HTTP e...
Suppose I have long method like this: public void SomeLongMethod() { // Some task #1 ... // Some task #2 ... } This method doesn't have any repetitive parts that should be moved to separate method or local function. There are many people (including me) who think that long methods are code smells. Als...
I am working on a project of an online service provider. I have tables for admin, agent, customer and tables for data storage like city, services, category, sub-category, gender. I have created classes for the admin, customer and agent. But should I create classes for city, services, category, etc or use as methods in...
EDIT: The project is about creating an algorithm for Procedural Content Generation for a videogame. The actual game is secondary to the algorithm. It must be something basic to test the Procedural Content Generation. I'm approaching this as a single developer. Thanks to @ThomasOwens I realize this question is more abou...
Background I've recently become the technical lead/senior developer for a small R&D/data science team. I've got a decent amount of non-lead experience in bigger development teams, but I've not got any formal education in project or team management. There are a few experienced programmers on the team, but the others hav...
For a data structure with indices (e.g. an array list, a dynamic array, etc...), should the indices be of type size_t or int? Is there a clear reason to use one over the other? fooGetByIndex(struct foo* foo, size_t index); or fooGetByIndex(struct foo* foo, int index); Until I had it suggested to me to use size_t I'd ...
I'm currently creating a small single page app for myself. I'm using Angular and ASP.Net Core 2 Web API. On the server side, I'm also using the DDD approach (just for learning purposes, the app isn't big enough for using DDD reasonably), therefore I'm mapping my Domain Entities to DTOs. Here is an example of an domain ...
I often hear about agility processes, but it seems to me that it is (nearly) always tied to team organization and delivery processes. It (nearly, once again) never comes to the bottom of the bottle: the development itself. Are there any agile methods which specifically target technical issues, like development methodol...
Let's say we're talking about a webshop. Microservice 1: Manages products and their prices Microservice 2: Responsible for payment and checkout. If a user wants to pay for a product, the payment service is invoked. The service has to return success or failure synchronously. Also the service has to guarantee to use ...
I've been trying to make my code cleaner and I have came across an issue which I don't know what the best solution is. This is the code I want to "clean". Please bare in mind that I am refactoring this code and its is not complete. I have replaced code with comments so to focus on the target issue. void Order::cancel()...
I would like to create a system which handles alert messages from various programs and can process those alerts to down-wind consumers via email. This would all be contained over one internal network. I think I want the basic architecture to look something like this: The main concern I have currently is the "Message H...
I am trying to write a rest GET api to serve query results. The entire flow happening on the server is: Fetch user data Call the first query, if results generated: return results, else continue Call the second query, if results generated: return results, else continue And and continue so on. The problem is I w...
Consider this simple example: def a(val_x, val_y): return 5 + b(val_x, val_y) def b(val_x, val_y): return 1 + c(val_x, val_y) def c(val_x, val_y): return val_x * val_y Passing the arguments val_x, val_y from a to b to c seems like a common code smell (I know it is something I do all too often when protot...
I currently am in charge of networked linux based hardware that exposes HTTP connections. I want to be able to connect to these through HTTPS, but the hardware deployment has 1000's of installations. I've read about problems with self-signed certificates and am unsure how to proceeed. Furthermore, some of these may...
Both the comma operator and the semicolon can be used to separate statements. Let's consider this simple code: #include <stdio.h> void do_something(int*i) {(*i)++;} int main() { int i; scanf("%d", &i), i++, do_something((i++, &i)), printf("i is now %d\n", i); if(i == 5) printf("MAGIC NUMBER\n"...
I am working on a huge application in php which contains almost 600 tables to work with, not to mention it requires complex joining for 10 or 15 tables together. i wanted to ask how much ORM is good to use for this kind of task? i know i can pretty straight forward achieved this writing raw queries on database layer. S...
I have a model where Sellers can sell Products to Customers. Sellers need to be able to set Preferences for Customers on a specific Product. I can see how that may be confusing so let me give an example. The Seller is selling Shoes, so he wants to set specific Shoes preferences for Customer x (colour, material, brand, ...
I need to compute the value of a row R on a table based on rows queried on another table B. I need to do it in a queue worker because the computation of the value can be slow. A message is queued everytime B change. If the two workers start the computation of row R almost at the same time, and the data on table B chang...
In our environment: Internal releases are those which went through testing process. Builds either pass or fail. External releases are those which are delivered to users. For external releases, version number is surely given. But is it necessary to assign version number for internal releases ?
Suppose were testing line segment intersections, and the intersections consider parallel and collinear lines to never intersect. Which one would be more natural to write? One case has more jammed into it and the scenario title seems broad, but prevents having to write a certain variable multiple times, but at the expen...
I know about MVC, But I don't have such experience with AngularJS. But both has controller and View. To develope like e-commerce site, is it good choice to choose AngularJS to do filtering with brands, or color, etc. I hope most of the e-commerce site are using SPA(Single page application). When I read about Angular...
Houses and cars have almost nothing in common for instance "number of rooms" and "gearbox". But if you live in an RV then I suppose it makes sense to have both. My problem is that I have a main data model named "Ad" for online classified advertisements and now we are going to expand the section about cars. Should I the...
I wrote a listener class that executes a programmer specified callback. The msg is provided as a callback argument. I realized that a programmer using the class will need to look at my code to see the structure of the msg. Is there a way of providing type hints to callback functions. Or should i refactor my callback t...
How do you cope with a team who tends to underestimate time needed to complete tasks and haven't been improving the accuracy of their estimates? Details: I work in a scrum team (7 engineers) in a FANG company, at the end of every sprint, we vote to estimate how many hours we need to spend on each user story for next sp...
The comments system that I'm using right now saves replies to a comment with that comment id as a parent. The problem is that that if the user of the main comment deletes his comment none of the replies of that comment will show on the page anymore. I think that's okay if only one or two comments are replies directly t...
Unsupervised learning (USL) is about learning/constructing the algorithm to find the hidden data pattern based on training data without hard coded business rules like arithmetic sum, etc. Example of USL is grouping customers with similar online behaviors for a marketing campaign. My question is why do we need training/...
Is it generally encouraged or discouraged to create a pre-processor macro in C, that facilitates the creation of many functions with the same signature (differing only in name). For instance, instead of: obj *car(const obj *args, obj **envp, GarbageCollector *gc) { ... } obj *cdr(const obj *args, obj **envp, GarbageCol...
I find this concept hard to understand. So in what situations we have solutions that are impractical or impossible like those P-systems try to implement? P-systems are described as: P-type [practical - type] This is a software with a collection of procedures. This is defined by exactly what procedures can do. In this...
Consider the following minimal example: class SomeException < StandardError end class Example @@logger = Logger.new @@failure_count = 0 def do_a_thing(array) raise SomeException unless array.some_check? # more random code end def some_long_process(array) array.each do |item| begin ...
After reading the last book from Robert C. Martin, I've tried a to develop some big Go applications following clean architecture. While writing interactors, I end up with a lot of complex unit tests, because the interactor has a lot of external dependencies. What are the best practices for testing the interactors? Shou...
I am new to an organization that has a release version number for their vision software and a different release version number for the supporting functionality (dvr, provisioning, etc) around that vision software. It is straight C code - everything is global, very tightly coupled and the components do not compile separ...
I need to make an HTTP endpoint with different return types based on query params. There are several options to do that: Return an object with one property set and the rest equal to null: public class ResponseModel { Type1 Property1 { set; get; } Type2 Property2 { set; get; } Type3 Property3 { set; get; } }...
// Car states : START, RUN, STOP // START ==> RUN ==> STOP ==> Write // CarFromStartToStop() : // Car is initailly at STOP phase. // We start the and car comes in RUN phase. // Then at the end car comes in STOP phase. // WriteCarResults() : // Writes car's current status. eg : oil status, odometer etc. class Info1...
Since when I used smarty I always tried to separate logic statements from html tags, so my approach to blade would be to write: template.blade.php <div> <div> @if ($something == true) <ul> @foreach($list as $item) <li> {{ $item->name }} </li> @endforeach ...
Imagine that I am creating and Ecommerce application. For sake of simplicity, I will describe only 3 bounded contexts. Product Catalog: it's responsible for maintain product descriptions, characteristics and so on Pricing: it's responsible for products pricing Inventory: it's responsible for inventory management. If ...
Back ground: 1) Waterfall model has it's own phases of SDLC: Requirements -> Design -> Implementation -> Verification -> Maintenance 2) Iterative model has it's own phases of SDLC: But the term Agile does not have it's own development methodology. Agile projects are mostly iterative in sofar . Is Agile an effort pla...
On the project I'm working on, I noticed that on login there is a check in backend which checks if the request is an ajax reques (checks 'X-Requested-With: XMLHttpRequest') or not. If the request is an ajax request the login is performed, otherwise the request if deniend. Nobody knows why this check is needed here and ...
People say that "talking about TDD hardly works, if you want to convince someone to TDD, show them results". However, I'm already getting great results without TDD. Showing me that people who use TDD get good results won't be convincing, I want to see that people who write both TDD and not-TDD get better results with T...
I'm developing a game engine in C# and I just had a question about handling exceptions correctly. Since the engine will be used by other .NET developers, how should I handle exceptions? What I mean is, in any other application that may be used by people outside of the development if an exception is caught, the program ...
I have a situation where some commands are using some common methods. These were originally developed in one command and are now helpful to other commands, they can be static and are self contained. public Command1 : ICommand { // does something specific to some records // tidying up fields before they go to the...
I have the following basic design points: Let's say I need to design 2 entities, ADecoder and BDecoder, which are almost the same, except for few details. Let's say both have a function decode() which of course would be separate in what they do, and there are some other functions as well, with the same characteristic,...
I would like to implement gambling website with the following possibilities: as a player I would like to get list of games As a player I would like to like games As a player I would like to see recommended games(based on likes or time spent on a particular game by users) As a player I would like to start/end a partic...
We develop on a ASP.NET Web API where we use the "Unit Of Work / Repository" pattern : Our Controllers looks like that : public class MyController : Controller { private IUnitOfWork _unitOfWork; private IMyService _myService; public MyController(IUnitOfWork unitOfWork, IMyService myService) { _...
These days we follow TDD across projects in the company. How as a leader I will know whether TDD is truly followed within a project? I would like to achieve this through automation that is instead of manually auditing, would like to see some tool to monitor the developers workbench constantly and alert if TDD approach ...
I'm not sure if softwareengineering exchange is right for the question. I need to populate view model with some values I query from the database. I do it like: var db = new NPoco.Database(connection); // Get some values from database //... var viewModel = new MyViewModel(db) { //assign values from database }; // sho...
I am writing tests for a project that consists of multiple submodules. Each test case that I have written runs independent of each other and I clear all data between tests. Even though the tests run independently, I am considering enforcing an execution order, as some cases require more than one submodule. For example,...
I am writing a simple compiler. I have written lexer and parser and it now generates assembly code from given code. Now I need to write an assembler which generates machine code. But the problem is that I want to make my compiler portable. it should run at least on major architectures. One way of doing it is writing di...
Is there a best practice for iterations inside of a "using"? which is better? and maybe a why? "using" inside of an iteration... foreach (var currentPerson in Persons) { using (var db = new SolutionModel()) { //TODO: run query } } or is it better to do an iteration inside of a "using"... using (va...
In official Microsoft docs: ✓ DO use a stable, version-independent product name at the second level of a namespace name. But in Reference Source, the following namespaces ends with Version: Microsoft.Build.Tasks.v4.0 Microsoft.Build.Utilities.v4.0 Microsoft.Build.Utilities.v3.5 So is Microsoft violating its o...
In the book Coders at work Joe Armstrong stated that: I think the lack of reusability comes in object oriented languages, not in functional languages. Because the problem with object oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you...
I am designing a library that abstracts a typical CRUD http service named FooService. In this library I am throwing different exceptions like FooServiceClientException for network related errors or FooServiceObjectNotFound when trying to retrieve an object by a non-existing id. I also have a FooServiceException from wh...
Situation I am currently refactoring existing web code. The code currently revolves around a ServerConfiguration object. It looks something like this: string UrlBase = "https://myserver.com/api" string UrlLogin = "/v1/login"; string UrlProjects = "/v1/projects?api_token={0}"; public string GetLoginUrl() { ...
public class Connection : IConnection { public Connection(Uri baseAddress, ISerializer serializer) { BaseAddress = baseAddress; Serializer = serializer; ResponseFactory = new ResponseFactory(serializer); } private Uri BaseAddress { get; set; } public IResponseFactory Resp...
If I want to create a conceptual model for my new application, and during the analysis, I found that some objects like employee, department ..etc are a part of another system. and all the data related to them like employee name or number exist in that system. My questions here: How to handle this case in my conceptual...
I've been reading Out of the Tar Pit by Ben Moseley and Peter Marks and in section 5.2.3 they discuss state in functional languages compared to procedural languages. The procedural example is as follows: procedure int getNextCounter() // 'counter' is declared and initialized elsewhere in the code counter := counter...
I'm putting together a talk of the history of best practices in software development and we're trying to put together a bit of a timeline of how good practice has evolved. This question talks about the history of Source Control and talks about how the first versions started to appear in the 80s but I'm hoping we can go...
While working in a multi-threaded environment, then data sharing seems to be a good option to pass data between threads. While working with real time systems it is apparently advisable to go with memory optimization. So, in my scenario, I have one consumer and one producer. They share one queue of any data type e.g i...
I'm currently learning functional programming and trying to learn a new concept : transducers. I'm actually getting the point of theory, like it's an advanced map/reduce that aims to provide better time complexity on array / object operations (such as transform / filter / reduce). Here's my current code, I'm feeling a ...
I have a function that creates a new object by passing to it's constructor integer ids primarily with values of 0. This function is called when saving a newly created record (not an edit). public class RecordController { private int _recordId; private int _subRecordId; private string _xmlData; private...
The issue at hand is dealing with user avatars that come from their social media accounts. When a user signs up with our app, the user will use his/her social media account and we simply save the URL to user's avatar in our database. We're now running into an issue because in a NoSQL database, we're creating many copie...
I only know that index is faster but don't know why is it faster. Suppose I have an array int[] a = {2,3,6,7}. Then I will try to find the element at a[3] and the speed of this will be O(1). Why? How it will know that 3 is placed after 2 boxes? So for more clarification of my question here is the structure of array I'm...
I am currently get a job and faced to a Table with around 900 columns in their database. I am not sure what should I do instead of re-design the database, Please advice me for this situation that I have. Queries for this Table is really frustrating when I need some of the data in this table and joining to other tables....
(Not entirely sure whether this should go in the information-security StackExchange instead; feel free to move it there if that's where it belongs.) Unicode has many, many instances of pairs or larger sets of characters with identical glyphs nevertheless being assigned to separate codepoints (for instance, the Latin ca...
I am trying to design a group of related classes. For example: one table class holds a vector of integer, and has a function returning integers from the vector another table class holds a vector of double, and has a function returning doubles from the vector Ideally I'd like to have the two classes share the same poi...
I want to fix my current Email Delivery system which sends email using a third-party email provider and creates a record for each email sent in RDS. Functionally this is how the system behaves - A user creates Campaign to send emails to their leads. A campaign can be sent to up to 1 million users A created campaign is...