instruction stringlengths 34 36.1k |
|---|
Would like to start off by saying, I am asking this as a purely academic exercise; I am quite happy to just continue to use the repository pattern.
I have heard "I put persistence methods in my business objects because when to persist was an integral part of the business logic" which I do not think is a valid reason, ... |
I read with interest this answer from Jeff Sutherland, co-founder of Scrum:
Q: What's your view on the Business Analyst and how it relates to Scrum? Is there a place for the role or should the skill set of that position be spread across/owned by the team?
A: The Business Analyst is responsible for clarifying the requi... |
I understand that the main code uses the factory to return an abstract pointer of the object desired, but it doesn't change the heritability of classes.
Can you explain in which context does the factory pattern reduce coupling?
|
I had a conversation with a few co-workers and the concept of thread safety for a data structure came up.
In this example, we have 2 threads: a main thread and a background thread.
For the following pseudo class:
class Foo {
Array myArray;
// Only ever called on the main thread
// This method will call into the ... |
Suppose I am writing a test method for an object.
This object replaces sequences of blank characters in a paragraph with just one single blank character.
I came up with this partition:
Sentences with 0 blank spaces
Sentences with only blank characters.
Sentences with blank characters in the beginning sentence.
Sentenc... |
I am trying to design the best way to send reminders to users for events they are registered for:
reminders should be sent 72, 48 and 24 hours before the event
reminders cannot be sent twice (so user A registered to an event B should receive at most 3 notifications)
if users register after one of the three intervals t... |
I have been struggling to understand the reasons why typescript developers choose the way they implemented inheritance.
What I would expect from any language supporting inheritance is these order of work:
The derived class initialized properties are initialized
The base class initialized properties are initialized
The... |
I keep reading stories from developers who state that once they are able to get the FP programs written in languages like Haskell, Ocaml, Elm and even Rust, to compile without errors, they are pretty sure that the programs will work correctly.
They usually state that it is mostly due to the type systems of those FP lan... |
Another programmer just started working in our team and submitted a patch. What required was to have something that compares and check a couple of conditions and set a property based on the outcome. The patch, in essence, is a class that implements the requirement as something like this:
class Processor {
A a;
... |
Is it bad design to have an abstract class inherit from another abstract class?
I have a single base node (class BaseNode) and 3 possible child node types (Sink, Process, and Source).
Is the inheritance between BaseNode and SinkNode good practise? If not what is another solution?
class BaseNode (metaclass=ABCMeta):
... |
I have written a WPF app which is now starting to suffer. There is no real way of adding new features to it in it's current state, it has become sluggish to use. This application started as a demo and has unfortunately been sold and then expanded upon (sigh).
At first it was just lots of code all on Main. It was rap... |
In this 2003 article by Stephen Figgins on linuxdevcenter.com, Bram Cohen's BitTorrent is described as using the "Fix Everything" design pattern.
A less common approach that both makes BitTorrent harder to grasp, but worthy of study, is Cohen's use of idempotence. A process is idempotent when applying it more than on... |
It's been considered for a reason, that using for namespaces/names is side-effect-prone, and generally, fully qualified names should be preferred.
I've come up with an approach on that, which I couldn't find implemented yet, so I created my own project.
Briefly, the idea is to define a set of macro which would unfold i... |
I've noticed something strange in a few open source projects that use Semantic Version. In React 15, the React team switched to semver. Similarly, the Angular team switched to semver in Angular 2.0.0.
Semver declares that a major version bump will happen "when you make incompatible API changes". In React 16 and Angular... |
I am developing a small application and trying my best to make it as professional as possible in regards to design pattern etc.
It is a JavaFX app, and my app works fine but I am uneasy at the fact that I am instantiating the back end in the front end. I tried my best to follow MVC pattern and I think I have so far, ... |
Today a colleague who is studying systems engineering told me that software design constraints and GUI requirements (Exs.: the software shall be develop in three layers: presentation, business and persistence; the GUI shall use an tree object to display the structure) could not be considered system or software requirem... |
I am working on a project which is split into multiple git repositories instead of just one. Each repository is for a library or an application. The libraries are used by the projects or other libraries.
So I often have to deal with multiple repositories, for pulling the latest change, for working on a feature which sp... |
I'm trying to better understand the pros and cons of REST. I think I have a pretty good hold on the core factors, particularly creating endpoints/URIs that better represent the resources in play and using hypermedia to eliminate coupling of clients and the URIs to the application
My understanding is that if clients ar... |
I am working on a C library (SlipRock) for interprocess communication.
The library currently exposes a simple, blocking API. This is easy to use, makes misuse (relatively) difficult (this is C after all), and will be (relatively) easy to implement cross-platform, once I get around to implementing the Windows port (whi... |
Git can generate patches/diffs for binary files as well as for text files.
I'm trying to figure out what encoding it uses for its binary patches.
Here is an example:
diff --git a/www/images/openconnect.png b/www/images/openconnect.png
new file mode 100644
index 0000000000000000000000000000000000000000..51a5d620083cafdc... |
I have a class library-- call it Services.dll-- which is a wrapper for some third party functionality. The third party gave us a bunch of DLLs and those "inner" DLLs call a WCF service.
Normally, when Services.dll is running, it lives within the web site's process, and uses the web.config associated with the site. So... |
Originally, in most languages, I would like to put constants into a class like that:
public class AppConstants{
public static final double HEIGHT_MAX=20.0;
public static final int COUNT_MAX=100;
public static final double WEIGHT_MAX=30.0;
}
but I found it is violating single responsibility principle, for ... |
Like this:
Campaign:
type: object
properties:
id:
type: string
description: "A GUID identifier"
referenceId:
type: string
description: "A consumers identifier they have used to map their own systems logic to this object."
name:
type: string
description: "'Great Campaign 2017' as an exampl... |
I am working on a team that is geographically distributed between Australia and the Philippines. Until recently, we have been using a single SVN server to maintain our code, with the server containing a few repositories (let's call them Client, API and Common), with Common code shared between Client and API via SVN ext... |
Say I have a lot of page with ajax. Is there any convention or recommendation on the format/structure of an ajax response? Namely, if there's an error, a server returns http status 4xx or 5xx and... what structure should a json response have? Should it be with the root-level key "errors"? What structure should an an it... |
I have a cpp project which source code I want to split into 3 groups and want to define structure for these files by creating folders with nice name.
First group are files related to socket communication. These files contains implementation of company protocol used over the UDP socket. In future there will be another i... |
In one of the projects the CTO has chosen to use a message broker in order to connect microservices. Is the use of such software aligned with the microservices theory?
Attempt to answer the question
In Sam Newman's Building Microservices chapter 12: Bringing it All Together, the author mentions seven principles includ... |
I am developing a safety critical embedded system and I am programming in C.
We have a set of const structure declared in memory and they hold some critical data. I want to make sure that any of these structure is not corrupted.
One option is to add a CRC field in the structure. But problem is I have to manually calcul... |
I have 2 types of users of my API: ones who want translated error messages and ones who don't. I've tried 2 ways so far:
return both translated and untranslated message (https://github.com/Mudlet/Mudlet/pull/936/commits/0479c3f3dcd3446da38d7e4c6bf19636f8adfa6f). I don't like this because it is least efficient both in ... |
So I am working on a software design using C for a certain processor. The tool-kit includes the ability to compile C as well as C++. For what I am doing, there is no dynamic memory allocation available in this environment and the program is overall fairly simple. Not to mention that the device has almost no processor p... |
I have a web site with several web pages.
Each page requires some JavaScript: i.e. different JavaScript for different pages, which some JavaScript that's common to every page.
Some of the JavaScript is long (e.g. 4000 lines of code).
I coded the JavaScript using the basic Module Export pattern described in Adequately G... |
Is a scenario a bigger picture with more details than a use-case or how much difference is there? I write a report where I prefer the word scenario but in my training we used the word use-case (in a course about OOP).
I program in SMV which is not OOP. IIUC SMV is a domain-specific language specialized for model check... |
First year of Software Engineering, and we're learning OOP within Java. Came across an extension task to gain more credits. But could not think of what to do:
First Step: Design a checkout system
Build a checkout system for a shop which sells 3 products say Bread, Milk, and Bananas.
Costs of the products are : Bread - ... |
I'm currently working on a site for a friend, converting a google sheet to a webpage (to reduce the time it takes to modify the spreadsheets and apply them to all users).
One particular page is currently in a Google Sheet form, since the main purpose is to serve as a way of 'tracking' users. There's a lot of data that ... |
Yesterday, I removed duplication in a file. The code was performing translations in a grid[i][j]. The duplication was between the code for the i-axis and the code for the j-axis:
For instance, I rewrote:
void redrawGridLine(int iLine);
void redrawGridColumn(int jColumn);
as
enum CoordSelector { I = 0, J = 1 };
//S in... |
This issue indicates that:
From my understanding placing the tag on the release branch before
merging (and not on the master branch) is in fact the correct thing to
do so it can be found by git describe --tags from the develop branch,
too. See #374
while another post:
I accidentally installed the 0.4.2-pre ver... |
Consumer-Driven Contracts: A Service Evolution Pattern presents the idea of contracts verification.
But how detailed is the contract?
Is the contract defining only a syntax of requests/responses? Like WSDL in the case of SOAP Web services.
Or does it describes also the order of messages, i.e., the protocol? e.g.:
O... |
I'm here today, because I'd like to ask you a question about porting application built with Qt5 to linux. I have been asked to port this application to linux, I don't yet have the source code, but I have Windows binaries, so what I can tell you at this very moment is that:
- it's dynamically linked
- it depends on (a... |
I have two asynchronous tasks that need to get completed - say they're "make a pie" (make) and "bake a pie" (bake). I also need to cleanup after everything's done - "clean the kitchen" (cleanup). bake depends on make, and I want to cleanup when things are done. However, there are a few complications:
If some nice pers... |
I've licensed a piece of software under the Creative Commons Attribution-ShareAlike 4.0 International Public License, but I may not want to allow others to use it for commercial uses in the future, so I'm asking whether or not I can change the license for future versions of the piece of software to other licenses such ... |
I understand the concept of RAII:
Use the destructor as a means to free resources, such as memory, or closing file handles/database connections. Coming from a Java background this was actually rather easy to understand because of the similarities to finally.
However, I do not quite understand when you actually should ... |
I work for a franchise and am beginning the complete redesign of the application that each franchise uses to manage its daily operations. It functions as a point of sale and scheduling application. Currently, each franchise has its own local SQL Express database. The desktop application runs in their facility and reads... |
I tried to be as clear as possibile in the title, but I'll be more specific to my situation.
Problem 1:
I have a Player with some slots which can hold items. Each slot is a Slot<Equippable> where Equippable is an interface just to group different items together: Armor, Weapon, etc. Now I come to face a problem: the P... |
COCOMO II expresses programmer capability as a different factor than technology experience. How does it measure programmer capability while abstracting his language and tools experience?
|
It is easy to eliminate tail recursion.
There are few curious cases where the not-tail recursion can also be eliminated.
Exhibit 1: Fibonacci numbers.
A naive recursive solution
fib(n)
if (n < 2)
return n
return fib(n-1) + fib(n-2)
leads to exponential complexity. An iterative solution
fib(n)
f_0 =... |
My experience has been using the hybrid approach per use case demand:
Where content on same page needs to be updated, we used AJAX/SPA approach
But when the page has a completely different layout/look and feel then we would always submit the page and a new HTML response was loaded from server
My question is on poin... |
Let's say we have 5 functional software requirements (R1-R5). Our software design results in 6 modules (M1-M6) or classes to be implemented. I am assuming that the design is more or less optimal, each module having a well-defined purpose and the dependencies between the modules have been minimized.
In one case the rela... |
I'm trying to reconcile my object-oriented/functional mind with programming in a language with C. Let's say I want to achieve dynamic dispatch in C, say I want to have a collection of tasks to execute. I could make a pointer to a collection of functions I want to execute, simple enough. However, let's say that the task... |
My Java application uses Hibernate as an ORM framework. I find myself often writing code like this:
Session session = HibernateUtil.getSessionFactory().openSession();
try {
session.beginTransaction();
// do some work, which might or might not yield a result which will be returned
doWork(session);
// it... |
Basically, I've been tasked to work on a Xamarin.iOS app (predominantly for tablets only) that would display a long scrollable form that contains ~200 controls (buttons, switches, text fields, etc...).
Normally, I would create an instance of the control, assign values to it's properties and then add the control to the ... |
The functional interfaces in java.util.function cover the vast majority of common strategies one might want to apply, but it's also possible to define your own @FunctionalInterface instead. In cases where your desired interface coincides with an existing interface in java.util.function should you prefer defining a cust... |
I have an application which takes an integer as input and based on the input calls static methods of different classes. Every time a new number is added, we need to add another case and call a different static method of a different class. There are now 50 cases in the switch and every time I need to add another case, I... |
I hope this question isn't considered to "open-ended"...
The company that I work for is concerned about their image and they would like to have more control about the publications into their official social medias. Two major drivers to achieve: gain control over the passwords and inspect texts that are being posted.
My... |
I have the problem statement to make an Object Model for.
Problem Statement: Every vehicle has an engine and a gearbox. A gearbox is composed of pulleys working according to predefined gear ratios. Cars have smaller engines with 4-6 gears while Sports Utility Vehicles (SUVs) have bigger engines with 4-8 gears. Heavy Du... |
I have a some domain modeling case: There is two domain concepts Worksite and Contract. Every Contract belongs to some Worksite. I've already found out that both concepts are own aggregates but there is still business rule that the validity period of Contract must always be inside the duration period of Worksite. So ho... |
Let's say I have a Person class:
class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string IdCard { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string Email { get; set; }
public string Credit { get; se... |
I noticed something strange when I tried to use public method of A class in generic class B of A but it seems I can't. Is it relate to restrictions on generics. I mean Cannot Create Instances of Type Parameters rule.
public class A{
public void a(){System.out.println("Hello!");}
}
public class B<A>{
public voi... |
I am a new to in programming, especially to C++.
At first I learned how I make functions (it was amazing).
But now that I've learned about classes (and objects) I am so confused... when I should use them? What makes them more efficient than functions?
Most example problems I try to solve using functions, not classes.
... |
I'm trying to apply some good practices from Clean Code in my code, but I'm stuck trying to figure out if my code has a [G34] code smell, which tells that functions should descend only one level of abstraction.
var tryToMakeAMove = function(line, column) {
if( board[line][column] === EMPTY) {
makeMoveInPosition(l... |
So I am new to design patterns and C++11, but I have been studying both quite a bit. I am working on developing a C++ application to process some data, and I was hoping that someone with more experience could tell me if I am on the right track.
So the application will take in a large 2-D array of data. Then there is s... |
Current project that i'm working has a requirement to capture data relevant to a session and store. Purpose of this is to use these data for the analytics. Clients would use these data to generate graphs, chart and etc.
For each client, 10 data points are captured within a minute(10 rows within a minute). As per the pr... |
I am familiar with the Traveling Salesman Problem, and many of the various approaches to solving it.
But is there a name for the following problem:
Given an existing (solved) tour and a new city, insert the new city
into the tour (at the start, between any two existing cities, or at
the end), such that the total i... |
I have a method that I want to write unit tests for. I'm going to keep it fairly generic as I don't want to discuss the implementation of the method, just the testing of it. The method is:
public void HandleItem(item a)
{
CreateNewItem();
UpdateStatusOnPreviousItem();
SetNextRunDate();
}
So thi... |
In Clean Code:
public class Point {
public double x;
public double y;
}
The author wrote about the above Point() class:
This exposes implementation. Indeed, it would expose implementation
even if the variables were private and we were using single variable
getters and setters.
This means I must burn my sch... |
I'm writing a library which will be a base for a turn-based battle system but i don't know what are the best practices for exception handling, has anybody some advice for me?
Should I catch every generic exceptions/ exceptions thrown by standard components (like lists,dictionaries,etc...) and then throw a contextualize... |
Sometimes in interviews, I may use recursion to solve a problem (such as adding 1 to an infinite precision integer), or when the problem presents itself suitable to use recursion. Sometimes, it might just be due to using recursion a lot for problem-solving, so without thinking much, recursion is used to solve the probl... |
I am developing Angular 2 payroll application intended for serveral user groups/roles - e.g. for accountants, for employee self-service, for managers. Each user group should have completely different page layout and menus. So - there should be separate *.html pages and - I guess - separate @NgModules for each *.html pa... |
I am experimenting with complex FSM frameworks. For one of the approaches I am considering I would like to have two types of function: plain function and special function. The exact meaning does not matter. I want to have compile-time enforcement that there is no more than one special function per block. I can play wit... |
I've a base class named API which is used by three objects(Server, VPS, SharedHosting).
Code:
class API:
def get(endpoint, params):
def post(endpoint, params):
def parse_response(response):
Server class:
class Server:
def __init__(self, name, ip):
self.name = name
self.ip = ip
@clas... |
Our software has several classes that should be dynamically found via reflection. The classes all have a constructor with a specific signature via which the reflection code instantiates objects.
However, when someone checks whether the method is referenced (for example via Visual studio Code Lens), the reference via r... |
Let's say there are classes D1, D2, etc. describing different types of an abstract class D.
Let's say there are SenderReceiver classes describing different ways of communicating for each D1, D2, etc.:
abstract class SenderReceiver {
abstract void Setup();
abstract void SendA();
public void M1() { /* Common ... |
Does / why does Java need to have void methods? Reference:
Any method declared void doesn't return a value.
As far as I can think, every use of void would be better served by returning a status flag, the object being invoked, or null.
This would make every call a statement that is assignable, and would facilitate bui... |
I am working on a project in C++, and I have a big CPP file with several functions in it. I am actually working on splitting all these functions into smaller cpp files to make it more readable. I was wondering if this process had actually a name? I was thinking about calling it "Refactoring", but this process seems mor... |
I have an app that collects data points throughout the day.
Each data point is stored in a DataPoint object (that is persisted in the DATA_POINTS) table.
I also have a DataPointRepository with basic CRUD operations, but also methods to get average, min & max datapoints.
At the end of each day I want to compress the dat... |
I'm working on windows forms application. Recently, I get new requirements that I don't know how to approach.
Users of the application will have one of two roles: Admin or User.
Admin can set a list of instructions to do when encountering different situations.
Normal users (User role), will get a pop-up window with th... |
For decades it's been the case that interfaces were only only (only) for specifying method signatures. We were told that this was the "right way to do things™".
Then Java 8 came out and said:
Well, er, uh, now you can define default methods. Gotta run, bye.
I'm curious as to how this is being digested by both experi... |
I'm making an application that collects timestamp and GPS data from a user's phone in intervals along with some other information.
Currently, every tuple generated is sent via TCP to my application server as soon as the tuple is generated.
Is this an unconventional way of transmitting data considering it could transmit... |
I'd like to measure, how well unit-testable is my code. I don't have a concrete idea, how it should look like, but my logic is:
There are a lot of formally checkable and quantifiable criteria for well testable code:
usage of global/static functions/variables,
cyclomatic complexity,
DI vs. wild direct instantiating of ... |
Background:
I run a two-sided platform with small businesses on one side, and users on another. As a part of our product I plan to introduce "websites" as part of the product.
Idea is: a local business has a domain, and then I want to "turn that into a website" based on one of our templates.
My setup:
Today we have a .... |
Selection Sort(A[1,2..n]:array of integers)
1.for i=1 to n-1
2.for j=i+1 to n
3.if A[j]<A[i]
4 swap(A[i],A[j])
I am trying to prove the correctness of this algorithm,I read from my book and here is what is written:We must have 2 invariants for the inner and outer loop
The inner states:Every time we reach li... |
I'm working on a problem that requires a "sub-linear" solution.
A quick search for sub-linear will return a lot of this...
... where the sub-linear line is modelled as logarithmic/asymptotic.
But I had come to understanding that sub-linear was anything that remained below the linear baseline, as the both tended toward... |
Looking at the two data structures and algorithms to handle them, a hashmap is not really any more complicated than a binary search tree and possibly less complicated. And the hashmap has the advantage of constant time access of a key. So why did we get a std::map very early on in the history of the standard library ... |
The design of SLF4J really excited me. I mean the way it introduces the implementing component. In the LoggerFactory, it imports org.slf4j.impl.StaticLoggerBinder, a class in its namespace but that doesn't exist in its jar file. The implementation (like logback) jar just includes the class and it's done. The classloade... |
For some time I used PUT or PATCH in order to update a REST API resource. After using a lot of PUT/PATCH calls I noticed that "update" could be also done with POST.
Here is an example which is oversimplified that will hopefully explain the situation. There is an endpoint /api/cars/dealers/1 with a resource
{
"id": 1... |
I have large list of strings. Each string is of different length, just like sentence in text. Average length is below 255 chars.
Please, propose file structure on disk to enable fast picking of random sentence. This means I need fast:
* read total count
* read N-th string.
There's no requirements of writing time. It's ... |
I am an amateur developer and all my programs up to now were simple enough to be documented within the code. While reading the code it was clear what I was doing such and such action (my standard test was to look at the code 6 months later and understand everything at first read - and I have short memory span).
I am no... |
I have a pretty simple bash script which consists of a bunch of one liners and some simple logic.
Its been recommended that I rip the bash script apart and rewrite it all in python using subprocess. The argument was that we are building a python project, and that this way is more pythonic.
The only advantage that I se... |
I'm writing a function in the node.js-style asynchronous way, but how do I know if these functions are truly asynchronous, i.e., that they run in parallel and not sequentially?
Here is my code (modified to remove details):
// write the async function
function compileData(data, callback) {
try {
// ... do all the ... |
I'm developing an experimental application for work that requires fully persistent undos and redos. I decided to use react/redux/immutable JS tech stack to solve this problem because I saw it worked out nicely.
I'm actually really happy with the simplicity of the solution but my issue with this decision is that this ar... |
Many moons ago I built a utility library that wraps the JDBC libraries with classes that allowed for functional-style approaches. I've used this library for my own purposes for many years. I've long wanted to make this into a proper open-source project. I started at one point and then got busy with life. With the n... |
How do package managers deal with packages that use a package name but then abandon it or from rogue package names that are similar that host malware in the hope that an unsuspecting developer will install it? For example:
> gem list -r viewport
*** REMOTE GEMS ***
viewport_units_buggyfill (0.1.0)
This package hasn't ... |
only one thing after discuss my doubt i am a mobile developer and i am trying to adapt DDD, and i say adapt because a lot of information is related to backend applications
My doubt start because i have a User class that is part of my model (im using MVP), and also in terms of DDD it´s a domain object, i know business l... |
This is a design question where I am trying to accommodate a business need.
I have two entities - Item and Job.
Original Situation
Item represents a line item on a ledger, and Job is created only for those Item objects that need it (i.e. a Job to track the line item going through the status change process as it went fr... |
I have a set of machines that I'm going to setup to push data to my web server over HTTPS at regular intervals. These units will automatically send requests using a script, so I plan on giving them configuration files with a username and long password for authenticating with my server.
Is there anything I should do in ... |
How do we manage dependency injection in class libraries? Given the following class structure, we would like to inject an instance of Bar into Foo, and we would rather not make this the client's responsibility.
namespace MyLibrary {
export class Foo {
private readonly bar: Internal.Bar;
construct... |
I am writing a ticket system in PHP(with Laravel) for about 350 users and around 200 machines. I know that already are good solid solutions available, but I'm doing some very useful projects to learn, projects that I can implement in my company, with a good number of users to test it.
So, I want to know if it is possib... |
I'm working on a project for a course in college where we plan to build a mobile app for students, professors and administrative so that they can reserve an order in our local restaurant at a given time and then pick it up.
Currently, we have identified 4 roles and these are the restaurant manager, the cashier, the co... |
I've browsed around about Quasar fiber yesterday and it seems that it's more lightweight than Java thread based on the following demo. My questions would be:
Are there any scenarios that thread is more appropriate than fiber?
On what scenarios should I avoid using Fiber?
|
So, reading golang blog on slices there is a snippet by Rob Pike
A weakness of Go is that any generic-type operations must be provided by the run-time.
which I don't quite understand.
Can one rephrase same sentence?
Considering the context before and after this sentence I assume we can not program generic-type method... |
In general, how do websites handle file uploads when they scale horizontally? Obviously if you have a load balancer going to 10 application servers, and each application server just saves an upload to it's file system, certain files will end up returning a 404 depending on which application server the load balancer pa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.