instruction
stringlengths
34
36.1k
For this question I want to present my current design and my idea of using a trait. I would like to know whether my understanding of traits is correct and whether my problem can be solved with another design not involving them. My current class hierarchy in my framework looks like this: interface IPage { /* ... */ } in...
Brief description of my project structure. I have some base classes like BaseView, BasePresenter ... . Also my project consists of modules, module represents one complete part of the application. Each module has it own Presenter, View ... But also each module has it own Base<ModuleName>Presenter ..., where specific m...
Let's say I'm programming a chess game. At some point I have to check, which moves are valid for a given piece. What would be the proper way to select the correct pathfinding function for a given piece (king, queen, etc.)? I came up with three different approaches: Store the pathfinding method (alongside the other dat...
When I attended an interview, the interviewer asked me "Is MVC used for Windows Applications?" But I said no. Is my answer correct or not?
I am working on a project in C++ that has the classes Driver, User, and Admin. I am including this classes in the UML diagram of my project. Now, there are many client functions in my project which do not belong to any classes but are placed in specific header files according to their functions. For example, I/O functi...
Before you start reading: I didn't know if I should post this here or on Workplace, but since my question is more about the "programming language" part I thought it would fit better here. My apologies if it's not the case. Also, I'm aware there is a similar question here, but the context is slightly different and I tho...
What is the best way of preventing of events from being handled more than once? Imagine a system where customers can place orders and when successful an OrderCreated event is raised. There are some separate processes which listen to events on a message bus. One process is to send an email to the customer, assume there ...
I am trying to implement Microservice to understand the architecture and how communication works. Many articles state that Services should follow the Single Reponsibility Principle, but it's kinda hard to achieve. For example, I have to search Item and get all the information (including stock). So I have two services: ...
I have to develop a logging system for my project which has multiple features. I am stuck at a choice. I could either make a centralized database and front end for everything. Or I could have one log table for each feature and a common front-end none the less. Centralized seems like the way to go but it has its disadva...
I'm creating an ASP.NET MVC application to work with data from an API that has a couple of different endpoints for different geographical regions. Each region has a name, an alphanumeric ID and a host URL. e.g.: Western Europe - WE1 - we.api.com. There are less than a dozen regions and their values won't change, though...
I have been tasked with developing a web based (i.e runs in browser) viewer for a proprietary log file. I have no control over the format of the logs, I just consume them. The log file contains binary data appended by a text message on each line, so part of each line must be de-serialized on read. What I am posing, is ...
"0", as a string containing one character, is not something empty intuitively. Why does PHP treat it as FALSE when converted to a boolean, unlike other programming languages?
To me this is a totally irrelevant unit-test and I don't understand why someone would spent time writing it, since there is very little value to gain from it. I would know perfectly well if this controller returned the wanted type by executing the method in a browser. Really, do you believe a test is needed for this an...
I'm designing an entity to represent a log-in object. The unique username value is an email address, that will go onto the username field. Should I add a second field called email to indicate a contact email address for the user considering that it would be valued copied from the username field? My requirements are em...
I'm looking for a formal way for a front-end and a back-end team to communicate on the shape of a JSON web API. For example, let's say you are on a client-side team writing the JavaScript & HTML for a AJAX SPA app. Another team writes the back end -- say, in Java. It's important that the data you see returned from thos...
In our organaziton to make the testing process a QA can start the QA process by deploying a feature branch to a QA machine. My question is that while doing so should the build process include running the integration/smoke tests as well or can we skip that. This makes the build fast and makes it easy for anyone to get ...
My office is trying to figure out how we handle branch splits and merges, and we've run into a big problem. Our issue is with long-term sidebranches -- the kind where you've got a few people working a sidebranch that splits from master, we develop for a few months, and when we reach a milestone we sync the two up. Now,...
I have a multi tiered project made up of three sub projects, i.e. Data access project, Business Logic project and Presentation project, where should interfaces be defined? I'm guessing that there should be interfaces defined in both the DAL and BLL.. In the context of testing the Business Logic Layer by using "test" da...
I am coding a Java EE application that provides REST services via JAX-RS resource classes, the application makes extensive use of CDI. My resource classes are @RequestScoped, the application returns HTTP Status 202 Accepted to the caller and executes the work asynchronously. I would like to return a "process ID" so th...
I want to write a few modules for ERP system, which is licensed under GNU GPLv3, and I want to sell them. However I don't want my users to be able to redistribute the code without my permissions. Considering the fact that I won't touch the code of the ERP system, but I would use it's API, could I do this? I've read a f...
I've looked around a bit and probably haven't found the right medium for this question so let me know if there's a different forum I should bother. First, there is an application managed by another group that does some simulations and communicates to our system via Ethernet. Let's call this App. Now, we have the foll...
I'm in the USA, and essentially only have visibility to coding languages in typical use in my USA-based business. These are primarily C++, C#, and Java. Are these languages that are common here also ones that are commonly used world-wide? To help narrow down the question, I am mostly curious about the former USSR co...
I'm making a Windows Forms app: It is client-server. Authorization, then load some data from server, then send back some statistics from time to time. You should go through a bootstrapping procedure, then it starts computations (a separate process). Then you can pause it anytime, probably scheduling it to start comput...
I have many Users for every Group. Each User has an array of objects in the following form: User.groups [ { "name": "My Group", "group_id": "1337xD", "is_admin": true } ] As you can see, each User contains a reference to the group they are part of. The application then makes a subsequent re...
I've found that there isn't a concept similar to "arity-based subtyping" in many languages that I've programmed in, where higher-order functions could consume functions of lower arity than their argument type, differing in a consistent way: say, preserving leftmost arguments in order, or requiring name-type pairs to ma...
A while ago I asked a question about custom text data formats, instead of using existing tools such as XML, JSON, YAML, etc. Now, in favor of converting our custom format to a relational database and some segments of JSON (in a JSON field), I'm running into the problem of 'data bloat'. By this I mean that there will be...
Abstraction - Creates barrier between representation & usage of List ADT Encapsulation - Ensures maintaining in-variants of List ADT. An invariant is a fact about a data structure that is always true (assuming the code is bug-free), no matter what functions are called by user. With this understanding, below is th...
The assumption is that we're working on a large legacy Java codebase - with active ongoing development. I had a team member say: We should use lots of smaller JUnit tests that are focused on one class - because the fast feedback and ease of maintanence gives us value. I had another team member say: We should focus...
In Python, if you have a classvar, it's accessible from an instance, but if you set the variable on the instance it doesn't actually change the classvar, rather it assigns a new name which shadows the parent value: >>> class Foo: ... classvar = 10 ... >>> f = Foo() >>> (Foo.classvar, f.classvar) (10, 10) >>> f.clas...
If in class diagram I have a parent "Account" and three childs "Child1", "Child2", and "Admin". The "Admin" has control over "Child1" and "Child2" accounts. Will the relation be like this?
I need to work with some payment gateway API. The API is divided into two parts. There are some methods based on REST and a few methods accessible through SOAP webservice. I would like to create some bridge to combine it into single API class in my application. However I am not sure it is a good choice. The question is...
I am working on an app for universities. The case is this: Each university has several academic programmes. Each programme has many subjects (modules). Each subject can be offered in different locations. The academic year is split into terms and each term lasts for a number of weeks. Not all modules are offered in the ...
I have a SQL query that is around 50 lines long. I'm wondering what would be the be the most maintainable and readable method for executing this, as it looks quite large. So far, I have thought of the following options: Create a stored procedure in the database SQL query is inline, in the method Store the query as a S...
Let's say I'm having a domain-model and I want to read and save it from any persistence layer - right now it might be a json file but in the future it could be xml or a database (which might also change in its type). To generate the domain-model from the persistence layer, I've got an implementation of a simple Interf...
My scrum team consists of developers who are experts in various fields. For example, we have two front-end and two back-end developers. Assume our velocity is 10. It seems that we can put tasks which sum of estimated story points is less or equal to 10. We have task to do something on front-end side and this task esti...
I am wondering if there is a difference between Haskell's type classes and Go's interfaces. Both define types based on functions, in that way, that a value matches a type, if a function required by the type is defined for the value. Are there any differences or are this just two names for the same thing?
I have the following problem- About ~60 tables on SQL that some have foreign key to each other,primary key as identity had to change to something else with logic. It was replaced by triggers that checks what is the next number and change the primary key field (by sequence) Now this makes several problems on EF when try...
So, I have Aggregate root that has some sub-entities with some sub-value objects (classic DDD design). I wanted also to use Event sourcing in Aggregate design. In AppService layer I receive Command, decode it and call method on the aggregate (I understood that this is common practice in ES): public class AgRoot { ...
Irony includes two phases. In the first phase it create a parser tree. After that its optional to create an AST tree. What are the differences between the parse tree and the AST tree? What is the reason to implement that?
Implicit typing in languages like C# permits compile-time type checks without necessarily referring "directly" to a target class: var toy = SantasWorkshop.Build(); toy.amuse(); In this scenario, we don't need to know what type of toy it is. And yet, we'll still know at compile-time whether our toy fails to amuse(). Ho...
In my basic understanding of ByteArrays the benefit is that it is smaller in file size. The down size of a ByteArray is that for any given format you have to know the about the file format to get information out of it. You need a specification and software tools or software to find information. For example, to get inf...
Good day, I'm a beginner in Java and I was wondering if, in Java, I'm able to do a beta reduction with a given lambda expression in Java. Basically lambda reduction is like this: 1.) Expression : (λa.abc)x Beta-Reduced Expression (without parenthesis) : xbc 2.) Expression :(λabc.abc)x)y) Beta-Reduced Expression (wi...
When submitting an app (especially iOS and android), there are some different size of app icons need to add into the app. Among of them, some sizes are optional, is it a good practice that I just provide the required icons that leads to submission fail when missing, and don't provide optional icons? My idea is, if I p...
So I am writing a method to check and throw if a new transaction is being made in another transaction. I first came up with straight forward checkNestedTransaction, but this seems vague since I cannot see what this method actually do.(like, when does this method throw) What would be the preferred name for this method? ...
In the framework I am using, I shall group things into models, controller, and views (I added services). When getting things out from database, it is pure data in array form. So they won't have methods with them. As the title asked, is it common sense to convert database data to object first? That is to say, I may the...
Here's the scenario: I'm showing to the user (let's call him UserA) 10 items per page, ordering them by date (newest first). As UserA still viewing page 1, another user (let's call him UserB) posts a new item. Then, UserA decided to click on page 2. Now UserA is surprised to see the last item that appeared in page 1 i...
With Oracle starting to collect license fees from different customers for using Java SE I've asked myself if the usage with a server runtime is still free. I'm no lawyer and all these licenses are more confusing than ever. There are BCL, GPL and others. As far as I read this the use of Java for software development and...
By the GPL v2, every modification of the program needs to be licensed by the GPL as well: "... by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or...
Our team is facing an issue adopting Scrum. We are a team with 10 developers a dedicated Scrum Master and a Product Owner. Our Product Owner is having issues with the Business Unit manager. He's a senior manager and he maintains the relationships with all their customers. In creating stories, sometimes there are missin...
I make use of an AngularJS style guide. Within this guide there is a style called folder-by-feature, instead of folder-by-type, and I'm actually curious what's the best approach (in this example for Java) Let's say I have an application where I can retrieve Users & Pets, using services, controllers, repositories and of...
I'm starting to design and develop a WPF application for my company and one of the first choices that I have to make is whether or not to use MVVM. The main points to consider are: The application is basically a VisualStudio-like editor, where designers will create projects and will define UIs by dragging and dropping...
Thanks to some great replies in a previous question, I think I now have a better understanding of GAs, but am still confused on a couple of points. I'll start with one here. I've been reading around about how a GA algorithm works, and have seen what appear to be conflicting opinions as to what you do at each generation...
OK, so please tell me if this is the worst idea ever, or if it might have some merit. Here it goes: I have a customer who uses a legacy application that stores data in an Omnis database file (*.DF1). This application manages reservations and bookings for campgrounds, and is locally hosted on a server that runs at my ...
Across the various different programs, you will most often have a menu item called: Preferences Firefox Chrome Gedit Synaptic (Under a Settings menu column) Hexchat (Under a Settings menu column) Gnome-Terminal Thunderbird Rhythmbox Less often: Options QtCreator and less often: Settings Gvim Chrome Preferenc...
I am very new to the software industry. I was assigned to implement keyup search or real time search for a web page. I need to search employee code. For example, employee code is like TM-00001. If user types T then search box will show all the employee codes with prefix T. This is very basic and I can do this by using...
I am a intern student working on a project. We have the need to use a dynamic layout. Originally all that we needed was to know whether or not a search input should appear in the navbar and what catalog that should search on. Now there is more meta-info needed about the search and other dynamically displayed side bars....
I have a class used to process customer payments. All but one of the methods of this class are the same for every customer, except for one that calculates (for example) how much the customer's user owes. This can vary greatly from customer to customer and there is no easy way to capture the logic of the calculations ...
Our project methodology is recently migrated from Waterfall Model to Agile, and the development and QA team is given proper training on that. Now, one of the Agile Strategies is "Small Feedback cycles". But our product owner is still giving feedback after 2-3 sprints. That in turn results to major functional changes in...
Sometimes I come across the situation that I have some data in a nested dict with rather long key-names (sometimes unavoidable for one reason or another). some_dict = {'not_too_short_key_one': {'second_lvl_key_one': 23, 'one_more_second_lvl_key': 5}, 'not_too_short_ke...
I have an application, that can run on both Windows and macOS. I want to apply a digital signature to its binaries. I have already got a Thawte certificate (with private key) for Windows. Can I use the same certificate to sign my macOS .pkg installer?
For example: if I'm modeling a system that handles the inscription of students in a library and the documents in it, should I create a class for the library even though I have only ONE library?
I want to confirm that my software works on an OS that is not installed on my workstation. So I want to use a virtual environment to test it. I am worrying there are disadvantages about that. Are there disadvantages for testing software in a virtual environment? OS what I mean, operating system.
I've taken a deep dive into the world of parsers recently, wanting to create my own programming language. However, I found out that there exist two somewhat different approaches of writing parsers: Parser Generators and Parser Combinators. Interestingly, I have been unable to find any resource that explained in what ca...
In this article the author claims that Sometimes, it is required to expose an operation in the API that inherently is non RESTful. and that If an API has too many actions, then that’s an indication that either it was designed with an RPC viewpoint rather than using RESTful principles, or that the API in question i...
I'm currently building the front-end of an application using AngularJS. I don't have a whole lot of knowledge about the back-end, but some of the data I'm being served by the back-end developer is becoming difficult to work with, requiring a lot of rejigging on the front-end, and I'm starting to suspect that we could ...
Let's say I have an interface: public interface IAccountStoreManager { bool IsUserMemberOfAny(string username, string[] groups, out string[] containingGroups); } The method signature of IsUserMemberOfAny was affected by my observation that the client class would check a user's membership in multiple groups. For e...
I am working in embedded software domain and my primary work area is development of firmware for various MCUs. I follow the folder structure as mentioned below for any firmware project to release the source code and docs as complete bundle (.zip archive) for customer use. XYZ-project-2.0.zip |-> docs/ ...
We currently have a classic n-tier application: DB / web service / front-end. It has other components, but it's the basic layout. We want to improve the application availability for 3 main reasons: Our host sometimes experiences outages (as they all do), and we want to minimize the impact on our customers, so for inst...
Let us say there is a project A, and i came across a project EA which extends the project. The problem is project A is not available under version control, it is only available as tarball releases. The project EA extends A by creating a new github repository and adding new functionality, most of the changes are concen...
I am currently deciding whether I should implement a new system with a web application as a front-end, or if I should instead produce an executable file using WPF. The pattern that I will use is MVVM, since it suits my project needs quite well. However, I keep being told that MVVM is much better suited to WPF developme...
I have two Actors: User and Admin that will interact with my system. Admin uses generalization to inherent use cases from User. I have a use case named authenticate that should have two different behaviors. The post-condition for this use case is: User authenticated. If User is calling it, it should only ask for usern...
Should I take the time to clean my code once it's working if it isn't clean? Cleaning can take a lot of time. My boss just need it working but I feel unhappy if my code isn't clean.
Most of the literature I've read about GAs suggests using a crossover value of around 0.7, so you take the first 70% of one chromosome's genes, and the last 30% of the other to produce one new chromosome. If you are picking the parent chromosomes by taking the top two (ranked by fitness), then I can see the logic here,...
Note: This question is somewhat related to How exactly is bytecode "parsed"?, but it is not a duplicate of it. In this question, I'm asking about a specific part of how bytecode is generated, not how bytecode is "parsed". As stated in the title, how are literals(such as strings, integers, etc...), encoded into bytecod...
Let's say I have a phone that can process 1 million operations per second and a micro controller that can perform 1000. Is there a way to tell how many operations a performed by a function or block of code is performing? I have a function and I can write it a few different ways, an example doesn't matter because I'm ta...
Everytime I make a http request I must make sure there is internet connection. public class InternetCheck { public static boolean isOnline() { } } class Httphandler { public static String login(String uname,String pass){ if(InternetCkeck.isOnline)//make the request } } What if I add logout,...
Engineering is typically the art of knowing what solution fits best to the problem. If I were asked such as Should I use singleton classes?, Should all database have views and triggers?, What is the greatest PHP framework?, Is C++ or Go better?, or Is RSA or AES more secure? I will most certainly answer "It depeneds......
I have an array with a large number of elements, and I need to find the k largest elements. For an idea of scale, let us assume an integer array of length 10,000,000, and k is 1,000. I see three potential solutions: This answers to this question on Stack Overflow suggest the selection algorithm to find the kth largest...
Sample Java properties file which is read by the properties class appl.component1.property1=value1 appl.component1.property1=value2 Custom class which extends the java.util.Properties class adding behavior to throw an exception when a requested property is not available. public class Configuration extends Properties...
Is it safe to say that a Container is the "program" or mechanism that manages IoC via DI, but it doesn't really change your initial design of DI to accomplish loose coupling? In other words, if I want to achieve loose coupling, say for a Logger, using a Container doesn't change that. It just manages it in case I had a...
So this is all hypothetical and theoretical really. This isn't a real system I'd have to architect, but its a good question. A company stores and reproduces contracts. Contracts can have many documents associated with them. There are up to 200 types of these documents that can be assigned to any single contract. Tha...
This is not an easy one but here goes. I'm working on adapting a JavaScript project (ACE Editor) to support two different targets but maybe more. Any way I look at it, it looks like a large task and no approach feels quite right. I started to create a class that extends a HTML web view. This is basically a web view, a...
Imagine you are in charge of a cargo ship: travelling along a fixed route or loop (A, B, C, D, A...) has a maximum cargo capacity At each stop you can: buy commodities, up to your cargo capacity, or sell cargo that you have already bought each stop has different prices for each commodity for simplicity, you can't ru...
So I'm working on an iOS app and I’m thinking about how to keep user profile data in sync between server and client. The first idea that comes to mind is to create a class called User. It would be a subclass of NSMutableDictionary. Then I would declare a shared-instance within User so all view controllers and other cla...
Imagine the main system with the following use cases : one person may register, and book a room. At the same time there is a mobile app which is derived from the main system which is enabling the same functions (register, book a room) with some added use case options. How to distinct these two systems in a same use-ca...
I came accross this question while designing a multi module application that communicates with events. All modules are loosely coupled and are not dependant on each other. They use common event-types to communicate with each other. The question is, where to put the common event types in this scenario? Let's assume we a...
I have multiple related projects in one Visual Studio C# solution, which in general have similar architecture of WCF business logic services and ASP.NET clients. In order to host these services, I have implemented custom ServiceHosting application, which reads binding and port settings, services list and NInject setti...
We are having problems in testing routes that modify the data in our API. For example the test that deletes a resource will fail if run the second time. Also due to business logic you can't create or delete some resources via the API (as they are created by other triggers, or as a user you can't delete data but only a...
A developer built for me a SaaS for document analysis and one of the library used is GPLv3. The developer has shared source code with me as GPL. Now if i want to launch that SaaS for public consumption do I need to share publicly the source code i paid the developer for? there are two usage scenarios. user uploaded th...
I am starting a startup and myself and my partners are having trouble keeping up to date on each other's code and how to implement their functions. Our code is very well commented, but each of us have over 100 functions written, and we are getting to the point where we are re-writing functions the others have written ...
So, we're all probably familiar with the example provided in most textbooks of the Liskov substitution problem involving a square inheriting from rectangle. The objection to this approach is that while a square “is a” rectangle in a mathematical sense, the parent class, rectangle, cannot easily described in terms of a ...
So in S/W Requirements how to know a correct use case ? for Example : this one here seems wrong but I'm not sure
I am new to design patterns, here is a classic example of basic mediator pattern that has 3 problems with it, first of all take a look at the application image, diagram, code and description: We use a DialogDirector to implement the font dialog box shown in the Motivation. The abstract class DialogDirector defines th...
I'm building a chrome extension that I would like to offer for free for a given trial period and then the users buys a registration key on our website for a forever version . I've built software previously, but I've never made something paid. Using my basic knowledge of cryptography and membership websites, I thought ...
For example, when working with arrays there are methods like indexOf() that works like this: if (array.indexOf("something")!=-1) { // do something or nothing } Why hasn't someone made a contains method? if (array.contains("something")) { // do something or nothing } Or add functions people find useful like: var f...
I want to create a class with static constants which are used whenever a part of an application want to access the database in any way. This way I want to remove all magic numbers and string inside my application code except at one place. So any time later any changes to the database model have to be done, all adjustme...
I would like to know if there are any drawbacks to having descriptive names for database tables and columns. This would be for a Java based web application, and most of the times I have seen database tables or columns, they have had abbreviations for the tables and columns, such as "CD" when referring to "Code". Would ...
I've been tasked with researching and making suggestions about refactoring/cleaning up some existing code in our code base. Presently, many of our projects depend on a Constants class, which contains all of the constants used in the library. While on one hand I get this choice - this object has a clear, defined purpo...
Let's say we deal with a quite naive, simple version of a database, which uses the classic version of redo-undo logs for failure recovery. For a "classic" request transferring an amount from one account to another one, the logs written at each stage of the transaction are the following: 1. TRANSACTION START ---...
I'm learning Ruby on Rails coming from Node.js/express and had a few design questions. I used React.js for the frontend in my Node apps and I'm planning on continuing to do so in my Rails apps. What I was doing in Node.js Have all requests starting with / be handled by a "view router". This essentially serves all the H...