instruction
stringlengths
34
36.1k
It is common to provide several image sizes with applications; anything from 16x16 to 256x256 and 512x512 for HiDPI monitors. Is there a reason why we need to provide all of them? Can we not supply say a 256x256 and then downsize it?
Should an error 500 only be thrown by the web server, or is it acceptable for your program to throw one itself? try { some bad code; } catch (Exception) { set_header_code(500); set_content_type('application/json'); set_response_body(json_encode({'is_error': true, 'message': 'An unknown error occurred', 'request...
I'm making a C program that uses GTK3 (best documentation ever) and OpenSSL (worst documentation ever) to simply encrypt/decrypt a file using a password. The encryption and decryption functions are both working, however if I enter the wrong password in the decryption phase, the file becomes corrupt (obviously). So I ne...
For example, the following function loops through an array which contains the name and errors of an input field. It does this by checking the name of the validating field and then pushing the error info to the invalid fields array. Is it better to be brief and write this: addInvalidField (field, message) { const foun...
How to handle cron jobs for multiple timezone? I am working on the PHP project that supports users from multiple timezones. I have used multiple cron jobs for multiple database operations. I am setting cron job to send push notification on the date of user's birthday. For ex., I am from USA and my birthday is 1st Decem...
I am working on a GIS platform that basically handles roads with features. The system uses an EAV model to store all the data in a database. The system has been around for a while and there is nothing I can do to completely change the database model. EAV was chosen because each installation had unique features with uni...
I am working on an embedded system that interfaces with the user with several buttons and a small graphic display. As a side note: Since I am on an embedded system, I would like to prevent dynamic memory allocation as much as possible. Something like std::vector is not even available. I need to implement a configuratio...
Context: I'm creating some applications to help me on my daily tasks, it does not connect anywhere and the only "data" it has to deal with is the parameters that I enter on the input fields. This is how I structured my solution: |- Helpers (Folder + Class Library) |- Core (Folder + Class Library) |- Shared (Folder + Sh...
This year I started using several Third-Party-Libraries (all open source) and I noted that some throw exceptions in a proper way (i.e. declaring exactly which checked Exceptions can be thrown by a method in the method signature), while others just declare throws Exception, which generally makes it more difficult to cat...
I'm developing a library intended for public release. It contains various methods for operating on sets of objects - generating, inspecting, partitioning and projecting the sets into new forms. In case it's relevant, it's a C# class library containing LINQ-style extensions on IEnumerable, to be released as a NuGet pack...
I've heard conflicting philosophies on this issue - or specifically, two conflicting philosophies. One is to check in the code as soon as the change is complete, so that your co-workers can see the change and to minimize any merging that has to be done when putting a build together. The other is to not check in any ...
Why is not it a common practice for languages to have method arguments passed inside method names? For instance, wouldn't something like: shop.Sell(15)Notebooks (although looking pretty unusual) be more readable than shop.SellNotebooks(15)? Also, this could simplify fluent APIs: instead of implementing additional inter...
Here my scenario: I have a client application that needs a dedicated powerful computation system that every seconds process some data in input (few kilobyte) and return a few megabytes of processed data that the client displays in a certain way. The algorithm to process the data has a sort of "precision" parameter so w...
In the W3schools tutorial on CSS3 media queries they recommend to have the standard layout adapted to mobile viewing, and have a media query "scale it up" to desktop format when viewing on a desktop instead of the other way around. This should make the page display faster on mobile devices. What is the reasons that it ...
I'm learning concurrency in Java and went over the tutorials on Oracle website. While I have understood some of it, a greater portion eludes me. I was thinking of a hypothetical problem (though it may or may not be a good case of using multiple threads) where I have 100 text files and I need to search for a particular ...
I am working on setting up a multi-tenant site, where users can select a theme. Each of these themes have different settings, so I would like someone to be able to select a theme and then when they edit their site settings it would bring up a form to allow that. I am sure I could do this through hard coding data, but...
I have developed a CUDA code that is a reimplementation of a (CPU only) C code. I would like to benchmark the performance of these two programs. I am wondering how to do benchmarking well in this case, as the hardware they are run on are different. For example, it would be unfair to run my CUDA C program on a $3000 GPU...
I have some question about the Composite pattern. I have implemented a model like these: Element is an abstract class, RegexElement is the "primitive", a sub class of Element and RegexBlock, the real Composite class, that has like instance variable a List of Element. 1) I would like to access to all the leafs of this ...
Intel 8085: In my textbook it is said: "Carry Flag - this flag is the carry out from the MSB of the A-register. CY is set after an ADD instruction if carry out was generated from the A-register." I get this, but how can be carry out generated from the MSB if the carry flag bit is located in the LSB of flag register-F? ...
So there is an Intel page about what to do about denorms. (BTW, I know exactly what denormals are and am quite familiar with IEEE-754 floating point standard.) I have two questions: What are the names of the system calls (in Visual Studio) to turn on these FTZ and DAZ bits so that denorms don't cause exceptions? What...
Basically what I need in my project is a number of some sort that iterates itself every time I build my project, and that I can output by my program. So for example, when generating audio, I need to add metadata that states that this audio file was generated by build #1551. After I build again, that number should go t...
For example, In NoSQL, technically replication and sharding approach is used for supporting large data. Was reading this article about NoSQL use cases. It mentions that NoSQL can be used for faster key-value access: This is probably the second most cited virtue of NoSQL in the general mind set. When latency is impo...
In Don Reinertsen's book - Principles of Product Development Flow - the tradeoff between release size (number of stories) and release cost (regression test cost and release cost) is described like this: In Ken Rubin's book - Essential Scrum - he talks about the benefits of smaller release sizes - being: Reduced cycle...
I am making an OO design for an app. So far I've come with this, I looks like it could work, but I am not sure of correctness of its design. Old design EDIT Okay so, I used factory pattern, and it looks good to me. Is this good design ? You are building application that will load data from several different advert...
I'm building a Json REST API for my application, and have some doubts about the design itself. My application has organizations and also equipment which belongs to organizations. That would be an example of the organizations API: /organizations: Loads all the organizations from the application /organizations/{id}: L...
This is a very simple function to find if a string is composed of unique characters. I believe that this is a O(n) time complexity as it loops once and has a single if condition. Am I correct? Is there any way it can be optimized further? public class Program { public static void Main(string[] args) { ...
I've been studying architecture lately, and came across the terms Event Sourcing, Event Streaming and Historical Modeling, all of them referring to "append-only" models, but all the concepts I've read so far are a little bit too abstract to me to fully understand the pros and cons of each one. I've gone through several...
I started a project using Slim3 and PHP using limited knowledge of application architecture. The plan was to create the project and separate application concerns. It was all going well, but things got confusing fast as the application grew. The whole idea for doing this was to make development easier. It does in a way,...
We have to write a library. Naturally, it should only have a very small API (as broad as needed as small as possible). The internals of the library are somewhat complex. Therefore, they need structuring. For the structuring I currently see two ways: 1. use packages. pros: the library can be neatly structured. Everythi...
I have an asp.net core project that is divided into the following structure Controller Store Repository The controller receives requests, and calls the correct Stores that are responsible for actions against the database (Create Users, Update Records, etc) The way I see it the controller should be agnostic to t...
I have had a discussion with my team about huddles; they want to do the meeting as a report written on slack rather than a face-to-face meeting. They consider that the meeting takes too long (it's 5 minutes long) and they forget what the others said from one day to another, not to mention that if someone mentions somet...
interface IUser {} interface IConcreteUser : IUser {} abstract class UserBase : IUser {} class ConcreteUser : UserBase, IConcreteUser {} As you can see, ConcreteUser inherits IUser two times - one time by inherting from UserBase and second time by implementing IConcreteUser interface. Is there something wrong with t...
Some languages claim to have "no runtime errors" as a clear advantage over other languages that has them. I am confused on the matter. Runtime error is just a tool, as far as I know, and when used well: you can communicate "dirty" states (throwing at unexpected data) by adding stack you can point to the chain of error...
I have a monolithic application. It is MVC, PHP, all on one server. It does get copied to another server or replicated. There are also older web pages that connect to databases that aren't related to the MVC app at all, adding to the complexity. I don't have a large team. I don't need big teams from various section...
I'm wondering whether measuring conditional code coverage by current tools for Java are not obsolete since Java 8 came up. With Java 8's Optional and Stream we can often avoid code branches/loops, which makes it easy to get very high conditional coverage without testing all possible execution paths. Let's compare old J...
The gist of what I'm trying to do is get an instance of the appropriate user service, then pass it whatever subtype of User we're working with. Models: public class User { public string FirstName { get; set; } public string LastName { get; set; } } public class Student : User { public int Grade { get; set;...
I have a SKU record which keeps track of raw materials used, pricing, cost, etc. An example SKU would be a Hamburger (1 bun, 1 patty, 1 oz ketchup, costs $11 make, priced at $4, etc). I need to add the concept of composite SKU's now, such as Burger and Fries Meal, which would have a Hamburger SKU, and Fries SKU, plus s...
Is there a design pattern or practice I can use to help with services that are either down or go down, while others are stable? What if I have three microservices, and two of them are good, and one dies right in the middle of a POST? Two will get the POST and one will not. I don't think I can do transactions because ...
I'm not sure what the best design is for returning an object that can both return a result for successful REST calls, or failed REST calls. I'm currently thinking of something like this (written in Java): public class ResultDTO<T> { public enum Status { SUCCESS, FAILURE } private Status status; ...
See this link. At the moment an extension is sorting the list through a tag (using a render hook?): <sort2> * C * A * B </sort2> Outputs: A B C However, the result is temporary in that it is kicking in each time the page is loaded and this might have downsides as the list grows. Can you think of another way to achie...
As the title says, can it be done? struct Room{ char *type; //Lecture hall, laboratory, etc. char *name; int *capacity; //How may people it can hold struct Building *building; }; struct Building{ char *name; char *type; //Administrative, school, etc. int *rooms; //How many does it h...
We have set(6-8) of API and it will be invoked in a sequence . there are cases, want to use output of first/second API in the third/fourth API . We have request object which is passed as input to all the APIs . we have defined all the response object in the same request and after each API execution corresponding respo...
I became the scrum master of a newly established team, that is responsible for creating a software AND maintaining other deployed application. So basically each team member has development & operations tasks. I have been observing how they work the past couple of weeks and I noticed that team is having troubles in coor...
This is a bit of a subjective question I guess but I was hoping for opinions on either side of the argument. So take this for example in C#: public interface IFactory<Tin, Tout> : IFactory { Tout Create(Tin param); } Now as you can see we take an input type and an output type, however a lot of frameworks often hav...
I am using SonarLint for Eclipse since recently, and it helped me a lot. However, it raised to me a question about cyclomatic complexity. SonarLint considers as acceptable a C.C of 10, and there are some cases where I am beyond it, about 5 or 6 units. Those parts are related to mappers where the values relies on differ...
Should I set up a shared account in our CI infrastructure to make it easier to use? My team uses CI infrastructure. When a developer first sets up a build he must enter his source control credentials so that the server can access the code. Thus the build is "tied" to a particular developer. I personally like this--I th...
I'm helping to manage an external team who are starting to develop new versions of some existing products. Historically, this team has always used a model of a single project in a single solution for about 30 modules in Visual Studio which go together to produce a deployable build. This is having a detrimental impact o...
While implementing one of my modules, I needed a singleton for one of my classes, say, ModuleManager. Instead of creating a class with singleton criteria, I created an interface ModuleManager to define the API and implemented this interface with an anonymous class so that there cannot be any other implementation or no ...
Let's say I have this function authenticate that returns a promise. The promise then resolves with the result. False and true are expected outcomes, as I see it, and rejections should only occur in an error case. Or, is a failure in authentication considered something you would reject a promise for?
We have a MVC Web API that is called to write transactions for a specific amount, where the amount is debited or credited to a user's balance. This records the balance pre-transaction (PreAmount), the amount, and the balance post-transaction (PostAmount). We noticed from a simple query using SQL Server's LAG and LEAD f...
I was recently debugging a bit of code where the previous implementation looked something like this: # controller for group/customers def index @customers = current_user.available_customers(param[:group_id].to_i) end # user def available_customers(group_id) # some other code, that sometimes returns early # ...
I'm developing a NodeJS API that will be consumed, for now, by an Android app. I need 2 important things here: a News Feed and a Notification system. And I need it to be scalable. I'm using MongoDB with Express for this project. Notification System About the notification system I'm thinking about a document that wou...
I have a manufacturing management application that I'm in the middle of redesigning to make it more universal (we acquired a small company and they will use the tool as well). Where before I had many values hard coded because the application had a single client, now it's more configuration based with various data eleme...
One of the OOP principles I came across is: -Encapsulate what varies. I understand what the literal meaning of the phrase is i.e. hide what varies. However, I don't know how exactly would it contribute to a better design. Can someone explain it using a good example?
Let’s say there is a REST API which allows users to create objects. These objects have a name. The name doesn’t need to be unique among all objects and doesn’t have any special meaning within the API. Should the API strip whitespace before creating the object? Pro stripping Most of the time whitespace (at least leadin...
I've developed an SPA using AureliaJS. We use team Foundation server to service our source control, but that doesn't really help with good versioning practices. For instance, with our WPF applications, we run a server build that adds a new build folder with a new version. This is helpful obviously because if we change ...
I want to make my application available in many languages. I started using Resource Files, but there is a little problem with them. I want other people to have access to these files. Visual Studio creates .dll for each file and that is not very easy to use. I want people to be able to see language files in an easy way....
Wikipedia says that the lexical process is often divided into two phases. The scanning process, and the evaluation process. Wikipedia defines: The scanning process as: The first stage, the scanner, is usually based on a finite-state machine (FSM). It has encoded within it information on the possible sequences of char...
I'm taking a comparative programming languages course and have learned the bare basics of variable scopes with respect to stack frames -- e.g. static and dynamic links, offsets, etc. as in the image at the bottom of this page for example. In our texts (two: Understanding Programming Languages by Ben-Ari and Concepts of...
I'm building components in Vue.js. They look like this: <template> <form :schema="form.schema" :options="form.options"></form> </template> <script> export default { data: () => form: { schema: { // array containing form fields } options: { isHorizontal: true, hasLabels: false ...
If I have a variable say x and set it to x=2 and then increment it, it happens in some systems that the variable after a number of increments reaches a max value and then resets back to its lowest value. Is there a general name for such a variable? Similar to "counting in a ring" or a modulo count for example x=1 x++ /...
If so, what is meant by not instantiable? If not, what other restrictions apply? What is the advantage of declaring a method as not instantiable in a supertype? When is this useful?
I am a beginner on DDD, working around small, simple domains in order to get my head on all the principles of design. I have this simple domain: institutions (Institution) and their available WiFi spots (Place) are kept in the database. No place can exist without an institution. Institution has manager user - assignee ...
I am creating new business web application and I want to achieve: Use the best technologies from their respective realms. I want reliable backend framework with solid ORM. And I want the most advanced SPA (single page application) framework with the use of most up to date HTML and Javascript features for the frontend ...
I was introduced to genetic algorithms recently by this MSDN article, in which he calls them combinatorial evolution, but it seems to be the same thing, and am struggling to understand how combining two potential solutions will always produce a new solution that is at least as good as its parents. Why is this so? Surel...
I am currently preparing a presentation for my software engineering class, in which I want to present the idea of package dependency management in Java on the example of "radial encapsulation" (http://edmundkirwan.com/general/radial.html). In order to give my course a more relatable introduction to this topic, I would ...
We are a project that for external reasons has to run in a Scrumish fashion. We consist of two subprojects : A backend data and services provider that I am a part of, and a UI+BPM layer that interacts with it. The backend also serves a few other consumers and both parts are implemented in two completely separate stack...
Objects tend to confuse me some. In understand the concept and use, certainly, but I feel like the functional paradigm is somewhat restricting my use of them. At the moment, I'm creating a simple code for a game of cards. Each player might have a simple object, like this: object player { name = "Steve"; score =...
Suppose I have a class A: public class A{ public void a(){ } } and class B use A: public class B{ private A a; } Should I encapsulate A in B: public class B{ private A a; public void a(){ a.a(); } } then new B().a(); or just let users of B access A directly: public class B{ priva...
I currently work for a company that has hired me to manage a website that has been installed by a former developer. I have access to the cpanel host and hold 100% authority to the website. with that being said, I barely know how to assemble HTML and CSS into a working blog theme on Tumblr. where shall I get started on ...
I have a “whiteboard” question. Technically I’d like to ask you about one thing I’m not sure in my design, but if you have time for a quick review the rest of the design - that’d be great. Every tip matters to me. So… I’m working on a simple game, turned-based (not an action game). Something like chess. For the client,...
How do game makers/engines like Buildbox, GameSalad, Construct, GameMaker, etc work in principle? I am not interested in getting a list of technologies (programming languages, APIs, etc), but how - from a software engineering perspective - do these programs convert the user's interactions into exportable code? What I'...
For a prototype project I've created an Angular 2 application with simple CRUD functionality using Auth0 to handle authentication with a back-end containing a Web API (core), Service and Repository project. I've chosen to use an Auth0 database to store all the user information (and not an internal custom table) because...
Recently, i have shifted from ASP.NET web-forms to MVC based projects. I was thinking about the state management is working for a MVC project. How the MVC page controls are able to retain the state upon any action such as click, checked etc. I was wondering, if there is any DEFAULT state management pattern for the MVC ...
There's a passage in Walter Isaacson's biography of Steve Jobs where Jobs moves Andy Hertzfeld to the Mac team by unplugging his computer and driving it over to the Mac building. This got me wondering: what kind of computers did the Mac team use to develop software? Clearly it's a standalone machine, since it can be un...
I am rather new to the concept of MVVM in C#/.NET WPF projects. The way I understand it, the view-model is supposed to lessen the amount of code-behind required to display data on a form. I try to do as much of the interaction logic as possible in the view-model, so any objects I will use get passed into the view-model...
Like the title says, is it a bad practice to create/generate the Object.equals() method because I need it in my unit tests, but not in my regular code?
Looking at posts such as this on StackOverflow, the consensus seems to be that you should hide incrementing ID's from external API's for security. However, I'm having trouble working out a good implementation. I don't want to use Guids as the ID, because as stated here, it leads to page fragmentation and when I did it...
If I have an abstract class Drink which has a derived class Coffee, what would the copy constructor for Coffee look like? If it accepts a reference of Type Coffee as a parameter then I wouldn't be able to pass an instance which has been instantiated like this: Drink* coffee = new Coffee(..); But if I accept references ...
If createWorld() is really long and I need to split it, I can split it to createLight(), createEarth(), createPlants(), and createAnimals(). So, naturally I do: function createLight(){ //work 1 } function createEarth(){ //work 2 } function createPlants(){ //work 3 } function createAnimals(){ //work 3 }...
I'm writing a very simple extension method that attempts to cast objects from one type to another. The intent of having this method is very similar to Int32.TryParse(string, out int), which allows the user to see 1) if the conversion succeeded, and 2) what the converted object is, all in one line. Because this method w...
I'm developing an whole ecosystem with an OAuth2 Provider, a Backend Server and a Frontend Server. OAuth2 Provider: provide only the authentication/authorization for the user, and a few other general purpose service. Backend Server: Implement all the logic and the models for a specific context, and is a OAuth2 client....
I've written a command line tool and I want it to print out the current version of the program if I type in the --version command. I've got a git repository setup for my program so I figured maybe I could somehow hook into that to get version information from tags or something? What happens when I type in program --ver...
I'm part of a team asked to perform some predictive analysis with a huge relational database. Data is a mess. Documentation ranges from mediocre to incorrect to absent. Information is scattered all over the tables. For example, if I want to match addresses with telephone numbers, I can query three or four different tab...
In SaaS multi-tenant database design, do you think it is sufficient to include the tenant id only in top-level resources, knowing that child resources will always be parent-scoped, or should every table include tenant_id as a foreign key? For example, if Tenants have Projects that have Tasks, is it enough to specify Pr...
I've been trying to mull over a question I am not sure how to solve and it probably has a simple solution however I am trying to work out a simple solution. The following scenario is as such. Let's say we have the following variables. string username; string password; string domain; string location; and I want to run ...
We are developing a SaaS product with which we want to give our customers the ability to produce “real time” (i.e. users should be able to get response within seconds) reports. The “raw” (i.e. not specifically materialized for reporting) data is in MongoDB and our front-end clients may be native mobile and Web. The que...
Scenario: Stack: Java, Spring, Hibernate. Model: Client-Server Application. Pattern: Model-View-Controller (MVC). The Service Layer classes has three behaviors: Some services have the business rule within the methods and delegate the persistence to the application. Like: EntityManager.save(entity); Some services si...
I've been developing applications according to the principles of DDD for a while now, and, as many, I often run into issues when it comes to persisting an aggregate. One of the main advantages of DDD is that it allows me to use the full power of OO design in my domain -- as such I want to use polymorphism and conform t...
I'm trying to adapt an algorithm to calculate covariance to work over a rolling window on the data. Wikipedia has an algorithm for online covariance: def online_covariance(data1, data2): mean1 = mean2 = 0 M12 = 0 for x, y in zip(data1, data2): n += 1 delta1 = (x - mean1) / n mean1 +=...
An image "size" can mean both the widthxheight or its weight. How could I edit this paragraph to not use the word 'size' twice? Allowed sizes: 300x250, 300x100 Max size: 300KB
I need to generate simple, 4 digits confirmation SMS code, which based on given information, e. g. username, or birthdate, whatever. So, for two identical inputs, I need two same output codes. I can't store this code in database. I'm writing in C#, and have been thinking about GetHashCode method, but he is highly not r...
Consider the following boolean array where dark == true: In this scenario the probability that a cell is dark or light is 50/50, but this may not be true for the general case. Maximizing only on density we see that cells 12 to 16 (inclusive) have the largest area with 100% dark coverage. Using this binomial probabili...
Which caveats should I be aware while localizing numbers in my front-end application ? Example: In Brazilian Portuguese (pt-BR) we split thousands with dots and decimals with commas. In US English (en-US) that's the contrary. In pt-BR we present the digits separated by the thousands, the same as en-US. But reading abou...
I want to ensure that I understand the scenarios which CQRS is intended. For example, if a web service has two types of clients: many external clients who will only query via GET; they will never POST/PUT/PATCH/DELETE an internal client who will primarily populate (via POST/PATCH/PUT/DELETE) the data store that the se...
I'm low man on the totem pole (consultant) who was pulled into a project for a large organization. How do you explain that this large organization practices zero industry standards and follows no software patterns? Yet everyone seems completely happy and convinced that nothing is wrong. This is the least maintainable, ...
Angular2 is based on the Angular-CLI, correct? So When I run ng serve there is a machine spun up at localhost:4200. Now if I want to add a database, a lot of people end up packaging Node.JS along and we have: Node server @ 3000 [or whatever your choice] Angular Server @ 4200 MongoDB @ port 12701 To me this seems redu...
What's the proper handling for a part of a script that is a non usable TODO case? Should throw an exception, a false assertion, crash the script or something else? By non-usable I mean it is not implemented, so that part of the script just does nothing yet.
I try to have find solution to get away from these heavy problems of number comparisons in Java... at least for numbers in a certain range with a certain precision with certain representation error. The task is to implement an equality check for numbers that are implementing the Number-interface of the java.lang packag...
tl;dr: Should I avoid exposing third-party types in a public interface? I'm working on a Kotlin-based project that relies heavily on data keyed with two values. It's just something I'm tinkering with at the moment to learn Kotlin, but I've been considering publishing it to a public repository such as Maven Central. ...