instruction
stringlengths
34
36.1k
I have this example class: public class Carrots { private string name; public void SetName(string pName) { name = pName; } public string GetName() { return name; } } I have the member of the class set as private and to set and get this member, I have made get and set metho...
We have a persistence backed object, and it has a version field in the database. Assume there's lots of unrelated code in this class. # # We're branching on this "version" field, and we return one # of 2 policies. # class Foo def policy if version == 'a' PolicyA.new else PolicyB.new end end ...
This is the code in question, comments point it out: class Actor extends Entity { private MutableVector2f position; private MutableIdentity identity; public Actor(MutableVector2f initialPosition, MutableIdentity initialIdentity) { super(initialPosition, initialIdentity); // !! pass to supertype !! ...
I have 3 Different Classes Which are representing different types of Sensors, for example: WaterLevelSensor DoorSensor TemperatureSensor Each Class has different functionality. Following the OOD Principles: I have decided to make 1 parent class called Sensor. Make the 3 different types of sensors inherit from the pa...
Recently i have been looking more into the design part of application programs. The suggestion seems to be very different across different sources. For example the books like code complete suggest to build into language or framework. Other approach like clean will suggest a more business or domain driven approach. Whic...
The only real logic is in the query syntax for the external API. I don't want to test whether it queries the api, I want to test that it queries it in such a way that the correct data will be returned. For example, some pseudo-code: function retrieve_related_data(id) { query = "[potentially long, syntactically comple...
Maybe too basic of a question but wanted to see if there is more to it than I am thinking. When configuring URLs (baseUrls, like https://my.app or relative URLs like /path/to/resource) either as a static variable, in configuration files or environment variables etc., what should my 'slash strategy' be? One of my cowo...
I have a huge time series (about 30 million) of network paths with the following format: timestamp, path, latency The path is a sequence of IP address, so it can be represented either as a string or an array of integers. Currently the data are stored in text files which makes it very slow the analysis and querying of p...
I'm making a console application, and over time I have been developing my own tools and practices for outputting text; a process that keeps evolving. For example, these days I have 4 main types of messages formatted roughly like the following: bold( red(" Error: ")) + msg << endl << bold(blue(" Value: ")) + invert(...
I've searched a lot for a clear explanation for a software architecture but each time I got more confused, so What a software architecture really is and is there a standard way to represent it or it's something generic that describes some software components?
I agree with all the fundamental ideas of BDD and try to use it as much as I can. However, one thing that strikes me is that the outside in development and tests that express a scenario need to have control over the client. The term outside in development refers to the practice of developing software by writing domain...
The scenario: I have a GUI with textfields and radio buttons where the user insert information for a 'Person' Here are the classes of the model and of the view-model: enum Gender { case Male, Female } class Person { var name: String = "" var surname: String = "" var id: String = "" var gender: Gen...
I am trying to solve a problem in which I have a list of two-dimensional coordinates, and I want to find the shortest path that connects all of them. At first I thought this was a case of the Traveling Salesman Problem, however: You don't need to get back to the starting city, which I believe TSP wants you to. On this...
Theoretically, is it possible to write programs without using variables? What will the most complex program look like? Does the answer vary depending on the language? Would you be able to use functions? Control flow?
I know I am reinventing the wheel. But I'm really interested in implementing arbitrary precision numbers (integers, rationals, complex, etc) in C or C++ and their algorithms. Please be patient. My question: How should I approach the process of implementation (and testing) of arbitrary-precision numerical algorithms in...
Another question was asked regarding the use of IP addresses to identify individual clients. I think I understand why an IP address is insufficient. But what about the socket, which has more information and, from what I understand, is stateful? Couldn't that be potentially used in lieu of a cookie?
I am modelling a system that requires a state-chart before implementation. Given These Images: Main Questions: Can I use the word "Elapsed Time" if I do not know how long it will take to finish the first state? Can I use event-based time instead of stating how long in seconds or mins? See the second Image for an exa...
I'm trying to write a program in Python that will take an input of a .wav (sound) file, and determine whether the user is saying "yes" or "no". The issue is that the sound files are not always the same length. I'm worried that with a static input dimension (i.e. 5 seconds of audio), I may have a sample that exceeds tha...
Recently, we have started to migrate a spring application to java 8. The application is divided into 3 layers, rest controllers, service and the repository layer. Our 'architect' proposed that our service layer, always accept a mapper function e.g. public <T> Optional<T> getCompany(int companyId, Mapper<S,T> mapper) ...
In my appliaction I am using EF. I have the service that can provide some information and clients who want to ask for that information. Let's imagine that I have a User, which has Address, the list of equipments, the list of subscriptions, the list of Balances. Each Balance has the list of Operations. public class ...
Note: The example in this question is for demonstration. Please focus on the question and not on problems in the example (such as tight coupling, lack of Dependency Injection etc.). I have a form to create a contact with a button for saving it. Here are the View and Presenter(written in C#). View: class View : Form { ...
Foreground We are moving from a monolithic platform to a more Service Oriented Architecture. We are applying very basic DDD principles and splitting our domain across different bounded contexts. Each domain is distributed and exposes a service via a web API (REST). Due to the nature of our business, we have services su...
I'm working with Xamarin and we are following the MVVM design pattern. For those who don't know what Xamarin is, it's a technology that allows us to build iOS and Android apps with shared code. Basically, your solution has 3 projects, one "Core" and then one per platform, the platform containing all the platform specif...
What is the reason to use release version as a release title on GitHub? It looks like this And it looks like a common practise. Almost all popular repositories use it. What is the use case to duplicate release tag to the release title? UPDATE: Examples: Facebook React, Atom, Kubernetes, CryEngine
Wondering about pros and cons around a facade pattern implementation (or perhaps there is a better pattern I should consider), versus simply exposing a dependent object to a caller. Consider the following: public class Model implements Player { private Player player; /* implement Player interface, which simp...
I have an application with a database that doesn't allow cascading deletes. When a user goes to delete an entity, I would like to display a popup saying something generic like, "This record has dependencies that must be deleted first". To support this, I was hoping to write some code that could generically take an enti...
It seems pretty clear that "Single Responsibility Principle" does not mean "only does one thing." That's what methods are for. public Interface CustomerCRUD { public void Create(Customer customer); public Customer Read(int CustomerID); public void Update(Customer customer); public void Delete(int Custo...
One of the first things I learned about dates and times in c# (and various other languages) is that a date is stored as a DateTime with the time component set to midnight. There is no difference between "Jan 1, 2017" and "January 1, 2017 00:00:00.000". If you need to display just a date, you can use formatting functi...
In addition to this question Should Git be used for documentation and project management? Should the code be in a separate repository? I want to ask if it is recommended to keep the documentation version (e.g.: for a REST API) the same as project version, assuming the code and documentation are in the same git reposito...
In my course, I have been taught that, in general, In general, a class B should be responsible for creating instances of class A if one, or preferably more, of the following apply: Instances of B contain or compositely aggregate instances of A Instances of B record instances of A Instances of B closely use instances o...
In many ways C# supports functional programming, but there is a (shrinking) list of features commonly found in statically-typed functional languages that are missing, such as tail recursion, partial function application, etc. Of these missing features, partial application is "fake-able" using existing language feature...
Background: I'm creating my first C++ game project and I plan on calling a InitialThirdPartySystems() function to...well...intialize all third party systems to be used in my code lol. Within it I want to do some checks to make sure all systems are initializing properly. However, I'm not quite sure of the properly way t...
I'm not sure which design pattern might help me solve this issue. I have a class, 'Coordinator', which determines which Worker class should be used - without having to know about all the different types of Workers there are - it just calls a WorkerFactory and acts upon the common IWorker interface. It then sets the app...
When you need to classify an object; what are the design implications for using a collection vs a member field (say a Boolean flag). So say I have a Client object, Client is either 'active' or 'archived'. Should I have two collections one for 'active clients' and the other for 'archived clients' and move objects from...
Please note: Although this question mentions Java and even a specific Java library, it really has nothing to do with Java and is really more about serial communication and device drivers. As such, I think this can be answered by anybody with experience in those fields. I've been in "Enterprise Java Land" for a while ...
I would like to follow up on this question, except that I have no code to show, so I decided to ask it here. In the linked question, the OP was looking for an algorithm which could generate a plane with only one OpenGL triangle strip. He came up with a solution that works almost perfectly: The order of the vertices fo...
In a library in Java 7, I have a class which provides services to other classes. After creating an instance of this service class, one method of it may be called several times (let’s call it the doWork() method). So I do not know when the work of the service class is completed. The problem is the service class uses he...
Say you have a big bloat of enterprise software and for every customer a different setup in terms of amount of appservers, search cluster size, webservers, database, loadbalancers and application-related staging functionality (edit -> live systems). Of course, you want to be as narrow as possible to your production e...
I have a factory for an interface with different implementations. But one implementation needs an extra method which the others don't need. How do I solve this without implementing "not implemented exception" methods in other implementations?
I always use implicit imports like from module import z, y, z but now I got a project, where all imports are done like from module import * and I'm trying to understand, if there any advantages of importing everything from the other module. Intuitively it looks for me like a very bad and inconsistent pattern, but mayb...
To make maintenance and versions tracking easier, I would like to expose the app version of each of the applications I develop on all my environnements. Can the app version and the last deploy datetime of my own application be considered as a sensitive information that should not be public ? Is it professional to do th...
I'm learning DDD. For a practice, I'm trying to convert my own app to DDD aggregates. What I understand so far on aggregate. Aggregate defines transactional boundary Design aggregate as small as possible If there is no invariant to protect, I might not need an aggregate. You need to load everything from an aggregate....
Is there a generally accepted convention for brace placement in F#? I found some examples in the documentation, but they didn't seem to be consistent with each other. In particular, and to take an actual example, is there a consensus as to which is better, this seq { for polarity, a in Set.filter (fun (polarity, _)...
I would like to build an application for sending emails. So I chose ASP.NET Core (API) which will be deployed by Docker. The application will get some request and "do some things" and then sends emails via Google SMTP. There's a Template that already exists ... so the system replaces tabs in the template with real data...
Why runtime ploymorphism is required ? give a real example that "why it came into existence when we have compile time polymorphism??" As mainting the runtime polymorphism requires lot of overhead of maintaining virtual tables and pointers. What are the benefits of "runtime polymorphism" over compile time with a good e...
Having used a lot of scripting languages, it's pretty simple to make a change. No compilation necessary. But now I have an ASP.Net C# application. It's small, so I can learn from it, but how do I make changes when they are small? For example, say I need to add a column to the API. I forgot one. What do I do? The a...
I have software that connects to several marketplace APIs such as Amazon, eBay, Etsy, and so on and imports it into our database. I've written a basic test. The test provides an order number for each marketplace importer. Each importer attempts to import it's order number. The test then asserts if this order exists in ...
We're starting to refactor one of our major products to a more microservices-oriented architecture. Presently we're using the Implementing Domain Driven Design folder structure to organize the source files. However, we're finding that the domain and infrastructure projects aren't doing a good job of organizing each m...
I am designing a web application that is supposed to be an 'entry point' for a few file processing tools. Lets call the main app the 'Connector' and the tools will be 'Tool1', 'Tool2' etc. The tools will be installed on separate servers and expose a REST API (my design). The files should be stored somewhere in a shared...
I had a C (programming language) teacher at the Lowell Institute at MIT who said this in the Spring of 1996. It's an overstatement, but still seems like a classic quote to me. I've had no luck searching for attribution over the years. I don't want to debate the usefulness of IEEE floating point. It is useful and I u...
I have been tasked with writing an on/off control for features in our product based on who is signed in, in principle with one on/off flag for each feature. Put simply, this is a permission based feature access that can be activated at the user level. The problem is that I can see this becoming a complexity nightmare. ...
I'm having a difficult time understanding when device drivers are needed, and when its fine to just talk directly to a port controller via the OS-provided serial/parallel/USB/etc. driver. For instance, Example 1: let's take OpenBCI, an open source hardware BCI that allows you to read EEG + EKG ("brainwave") readings. T...
Why we need compile PyQt rather than simply using 'pip install' to put PyQt to my package repository? What happened during the compiling? Can I compiled PyQt once but allow many Macs through share folder to import it?
To those who may not be aware, Bootstrap is a HTML, CSS and JS framework that can be used as a foundation or starting point in building a website or web application. I'm now in a position where I have an application in production that was designed with version 3 of the framework, but with additional styling that is con...
I'm in the process of writing Doxygen comments for this library of mine; it's a header-mostly C++ library, but it does have some code which gets linked rather than included. For that code, which has .h/.hpp headers - should I also add Doxygen comments in the .cpp file, for the library to be "properly" documented, with ...
Is there anyone seriously using C++ ATL or MFC at work these days? Please describe what kind of projects would require them these days.
I'm currently looking into a way of replacing all foreach loops with for loops in order to see the if I could gain some minor benefits in some legacy code that creates a ton of garbage. The thing is that it would take days to change all by hand in order to measure if the garbage removed would impact the performance in...
I've seen many companies that once used to follow plain old waterfall process claim to have switched to scrum and to be now doing agile development. But their software development process does not differ that much from what it used to be: Marketing/sales come up with an idea for a new feature They pass their ideas and...
We´re on the way to newly develop a WebApplication. We wan´t to make it a ASP.NET MVC app and we thought, that it will be the best approach to start with .NET Core. We started with project type ASP.NET Core WebApplication (.NET Framework). Has someone experiences with .NET Core in production? How is e.g. Entity Framew...
I have a Rails 5 application with Resque as the background job backend. A typical job does quite a few things, mainly it collects stuff from HTTP services, processes and aggregates some of the downloaded data and stores it in the local database via ActiveRecord. The question is, where should this be written? If it is a...
I have a model call Drug class Drug{ String drugId; String name; String strength; } this interface takes a drugId and returns the Drug Model interface IProcessor{ getDrug(String drugId) } // easy flow class ProcessorA extends IProcessor{ protected Drug getDrug(String drugId){ //get Drug from source A return Drug...
I've started to develop an application that allows the user to play notes on instruments. In particular, traditional Balinese instruments. As with many instruments, they have a certain amount of notes within an octave. Now I am completely out of my depth here on how to get started about the musical theory. My initial p...
I would like to compute a numeric value for strings containing only /[a-z0-9]/i (ignore case). Later, I want to use this value for sorting rows. For this post, I am ignoring number also. My thinking was, that I can define an alphabet like 0123456789a...z and compute a sortable value by summing up the indexes of each ch...
I am redesigning a large enterprise web system and a major concern has come across the table. The system allows for many users to Create, Read, Update, and Delete items in the system. This is problem if two or more users are editing the same file or item. What is a good technology or approach to integrate on this? Sev...
I have a simple entity class in my C# application that I would like to add additional properties to for use in the app. These properties will not be persisted to the database. In the past, I was told that the entity should mirror the object as it appears in the database, and that a separate class file should be used...
I'm developing a very complex wizard-style application similar to tax preparation software. The user is guided through many screens, each asking for some piece of data. Different answers lead the user down potentially different paths and there are dozens of screens they will ultimately see. This project started small ...
I have a family of products that currently houses 3 product lines. All 3 product lines share the same 4 options, but on top of those, each product line has 1, 2, or 3 different options respectively, individual to that product line. To illustrate: +---------------------------------------------------+ | Product Family:...
High level: I think my design pattern is flawed. Despite implementing Polymorphism, I find myself relying on large switch statements based on derived Type within my WPF application. As I'm adding more and more classes derived from my abstract base class I can't help but feel like my code it bad.. spaghetti code if you ...
In a development environment where developers are freely given root / admin access to their personal development VM's is there a need to prevent integration testers from having root / admin access in their personal testing VM's? The environment will use continuous integration and continuous deployment and aims to follo...
I'm designing a distributed game server which will support both browser and UE4 clients (hopefully both over HTTP for simplicity) and I keep butting my head against REST and doing semantic backflips to get the logic I want put in place. For some things, REST makes perfect sense - get a list of games, create a new game,...
Background: My team writers back ends, whose job is to receive input, perform calculation and either return the result to the caller or to another server down the line for additional processing. We write in C# and our code runs as Windows services. A few years ago we used to communicate via TCP with other servers (whi...
Background My boss gave me a project he gave up on, it's a CFF/OTF font subsetting + embedding feature. There is no deadline(well, it's more of a research project than a feature request). So I started with sfntly library and extended CFF support to it. I think I'm still in the early stages of the project as I just got ...
Overview I've got 2 systems over a network. The 2nd system produces some results based on the current contents of system A. How can I efficiently produce results in system B if getting the contents of system A takes a long time? Current sitation I've got a system, system A, that keeps customers (personal details, et...
I have a cms with some modules, and now I working on big update for it with new api. And I feel sadness when write updates for every single module. Too many things changed at this time. How can I avoid this in future? There is any recommendations for good api design? Google gives me advices only for making modules with...
I have a program which may accept several dozen arguments. I am questioning whether there is value in testing every possible argument. (In the examples, I don't have the exact syntax for pytest readily in my head. If the imprecise pseudo-Python is causing problems, I can edit to something more correct.) About half of t...
I have designed what I think is a useful, reusable functionality that I'd like to: Implement in C/C++ as an open source library; and then Write different "native binding libraries" for it in various higher-level languages, such that end users writing applications in these languages (Java, Ruby, Python, C#, Haskell, et...
There are two hard things in computer science: cache invalidation, naming things, and off-by-one errors. - Tweeted by Jeff Atwood Agreed. All software engineers can understand this. Choosing suitable names for variables can make an enormous difference in the readability of code. Very good programmers have an arsena...
I have a design problem, and no-one to help me thrash it out. Except for you. The system handles data files. Each row can be compared against a number of criteria, chosen by the user. The row is then true or false for that criteria. Each criteria also has a price and a cost (and a margin: price - cost). However, the u...
Hi i have a class like this class MyClass { private ExternalClass1 ex1; private ExternalClass2 ex2; private ExternalClass3 ex3 public String doSomething(String arg1){ val1=ex1.invoke(arg1); val2=ex2.call(val1); result=ex3.doit(val2); return result; } } unit test of this method @Test void doSometing...
I started very recently at a company that uses a rather unusual custom framework for their web applications, at least compared to the typical web application frameworks I know. Instead of a RESTful webservice an RPC mechanism is used to communicate with the server. Communicating with the server looks like a simple fun...
I'm trying to build a 'distributed' data system. My first attempt is built using Entity Framework. Very loosely, it's built around having Element objects, which themselves have a group of Property objects. Much like class objects and their properties. The reason is that any changes to these are synchronized between the...
I am struggling to find solutions to a problem that I encounter in a concurrent system (I am currently using the Actor Model). I basically have a diamond structure of actors: So D sends messages to C and B, which consequently send messages to A. Each part performs some form of operation upon receiving a message. As a...
We're in the process of migrating a monolithic application to microservice architecture. Due to some regulatory requirements, we have to keep client's data from different countries in separate (country specific) databases. I.e US db for US customers, UK db for UK customers... The following designs that we are consideri...
OK... I am attempting to implement a simple MVC windows application... There is a helper class (ConvertPDF) that is instantiated by the Controller. As it is currently implemented, the Converter directly updates the View and the Model. I have an inner feeling that this is just bad form! I have included these two assoc...
I have a Python script launching a C++ executable. The C++ executable is a multithreaded program that usually takes several hours to run. The way the C++ code is written, it will run on all the cores of the CPU if possible. However, when I run the Python script and check my task manager, I read that the Python scri...
I think the main difference between BSD and LGPL is that someone who modifies an LGPL library has to publish his modifications. I think this is usually a good idea because it guarantees that someone who uses my library is forced to contribute his improvements. I usually write code in Python and most of the libraries th...
I'm developing an application where users can create certain business objects (for simplicity let's just call them 'objects') that are stored in table in a relational database (the column names are trivial: id(int, primary key), name(varchar), type(varchar), and a few others that are not that relevant). The operation a...
I have noticed a pattern when I refactor my code for readability. When I refactor a method into several smaller methods, I often have to introduce parameters which sometimes (too often) makes the code less readable than before. I am wondering if this indicates that I should refactor to a different class, instead of jus...
Consider the following: #include <iostream> class Base { public: void go(){this->doSomething();} protected: virtual void doSomething(){std::cout << "base";} }; class DerivedA : public Base { protected: void doSomething() override {std::cout << "a";} }; class DerivedB : public Ba...
I already got the idea that string variables are immutable, so the they are copied to another place in heap every time we make a change, and since GarbageCollector has to collect them all the time, it causes performance issues.. Question is: Integers or doubles are immutable too. Are they also copied any time we mak...
There is a moment when you begin to understand that, in micro service architecture, it is more scary to wait a week to deploy all micro services at once to make sure that everything works together, than to strictly enforce api versioning, write lots of automatic tests (a bit of each: unit and exploratory, integration),...
I am learning React / Redux, and one feature I like is, when you fire off an Action, you actually provide a request as the "result" or what is called the payload in Redux, and the Redux middleware won't pass this Action to the reducers to compose the final application states. Instead, it will wait for the request, whic...
We are trying to work through an effective branching strategy for our organization so releases, versioning and such are all handled consistently. We have many C#-based solutions, each with anywhere from 2-60 projects. Each solution relates to a particular product for which we release updates on a regular basis. These p...
My question is which method below of defining variables is a cleaner way to code and why? Option 1: file_one=/path/to/file1 file_two=/path/to/file2 if condition cd(file_one) else cd(file_two) Option 2: if condition file=/path/to/file1 cd(file) else file=/path/to/file2 cd(file)
This is more about architecture question. I will be developing microservice in Lumen or Slim, it will not be accessible from the public. The private microservice will be dealing private stuff. Laravel backend will communicate with microservice via REST API (Private / Internal use only). Users will know nothing about m...
So I have an application that utilizes 14 different libraries. It's been a while since I have updated this application and one or more of the libraries involved have since experienced a major revision (using semantic versioning). That being said, I have just updated the application to utilize all of the newest versions...
I know function names can be very expressive. And therefore it can be tempting split up a program into particular functions and call them from a large "oversee-able" functions file. However is this actually effective for a programmer? Since each function usually relies on some input provided from a previous function, ...
I've seen this syntax in many places, such as when using javscript, thymeleaf(spring), properties files etc. //ex; in properties file. Where are the values coming from? ${someText} ${set.config.username} What is ${} actually called? I am trying to do research on understanding where the values are coming from when i...
We have many siloed legacy multipage applications. For example, a personal information collection application may contain four or five HTML4 form based applications. The backend is based on Spring MVC and there is no javascript on the front. For example, a user may enter the name information on one screen and click ...
If the question title was a little too vague or confusing, I'm talking about something reminiscent of the Mindstorms NXT/EV3 IDEs. But the code editor, instead of having prefabbed generic blocks to work with, would use just boxes with code inside of them that links to other code. I'm interested how this implementation ...