instruction stringlengths 34 36.1k |
|---|
I am trying to learn the Rules Design Pattern as described here: http://www.michael-whelan.net/rules-design-pattern/ (towards the bottom of the webpage). I have written a class like this:
public class OfferCalculator : IOfferCalculator
{
public List<IOfferRule> _rules;
public RulesOfferCalculator(... |
I'm planning on making a web app that'll use MySQL as the database, Java/Grails as the backend and JavaScript/VueJS as the frontend and then they'll communicate using only RESTful JSON APIs (that way I can have frontend apps running on any platform, all with the same backend). What I'm thinking is that every action (th... |
I am considering using a strategy pattern for configuration file management, that way I can support some legacy configs. I feel pretty solid on the overall design (as its pretty standard strategy pattern), but I am curious if the client should know the type of strategy that is being implemented or if that violates th... |
TLDR;
Is there a AMQP equivalent inside Service Fabric for Stateless services for communication between microservices?
I am building an application which contains multiple microservices.
For starters this application will have microservices locked behind API gateway. This API Gateway is publicly accessible from either... |
In CQS, does the "C" (Commands) require one class per query; same with the Q. That is the examples I have seen, but didn't see it really defined anywhere. Also, I do not mean CQRS, only CQS. I do not know where I'd use R at the moment, so I am only using CQS.
Edit: What I'm saying is something like this:
class Find... |
This is my first question on this forum, have tried to exhaust every possible research option I could think of or find. Actually this is the first time I've posted for help with this anywhere, so maybe I should have started here... :)
I am trying to build an automated scheduling solution for a pool league, right now th... |
I'm going through an introductory programming book and it lists a simple example in pseudocode:
Start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
Stop
Why can't we omit creating another variable called myAnswer and just put the operation into the output command, like this:
Start
input myNumber... |
I'm currently building an Android app that uses OAuth to sign in to a service. With OAuth, I need to provide a client ID and a client secret to the service so it can identify my app. Right now, I'm storing the credentials like this:
public class Creds {
public static final String CLIENT_ID = "THE_CLIENT_ID";
pu... |
Imagine that you're modeling SE (or SO) on DDD.
You decided to implement the "board" as an aggregate root. So the board has the method AddNewQuestion(string question).
There are business rules that dictate that a given set of partners (think companies that advertise jobs) should be notified about question tagged with ... |
Before I began developing a RESTful API I used a query similar to this:
$query = "INSERT INTO availability (user_id, date, status) " .
"VALUES ('".$id."', '".$date."', '".$status."') " .
"ON DUPLICATE KEY " .
"UPDATE status='".$status."'";
Yes, I know it's subject to SQL injection. Anyway, I... |
I built an app that display time series data. The display is very similar to a yahoo finance chart (ie https://finance.yahoo.com/quote/AMZN/). I am using Postgres to store the data because that was the database available to me when I was building it. The issue I am having is when I try to scale the different time frame... |
Background: I am new to testing in general, and have been studying it in context of JavaScript, specifically React.js, front-end development (actually new to this as well). For the question, I have these 2 similar cases:
Case 1: My code and a library
I'm using UI library and aside from its decent design, I want to leve... |
I have three resources Hotel, Address and Image. A hotel can have may images but only one address. While showing hotel details I need to fetch its address as well as all images of it so, in my controller the following code goes:
function getHotel(req, res) {
const { hotelId, merchantId } = req.params;
Hotel.search(... |
I have a web application (ASP.NET Core / C#) with 3 layers (web/presentation, business logic and data access).
I'm using Entity Framework to retrieve a record from an SQL Server database which is subsequently mapped to my model object. One of the retrieved columns contains an XML string where I need to extract some val... |
Please see the code below, which is a factory method in a rich domain model (domain layer). There are two things I dislike about it:
public class SalesPersonOfferFactory (Applicant applicant)
{
if (applicant.Age > 30 && applicant.Employed = true)
{
return new PersonOffer (52, applicant.... |
Our business team want long periods between deployments and once a build has been staged for their testing it must not be updated unless a fix is required.
This goes against our development team's agile process, which works on two week sprints and want to push changes forward as much as possible.
There is a business ju... |
I am trying to program a simple shopping scenario using event sourcing:
--------------- --------------- ----------------
| OrderService | | ProductService | | PaymentService |
---------------- ------------------ -----------------
|________________|_____________________|
... |
I've been working on a Python(Django)/JavaScript(AngularJS) based application for some time now.(I learnt all of these on the way, had previously been a Java only programmer)and have hit moments where the code was really unmanageable:
Single js script for the entire application, around two-dozen controllers, a dozen o... |
Say I have two machines with their own hardware and different specifications. They are PCs actually. The discussion here is if there is a way to put them online together such as their processing power could be balanced, like a cluster. Except, the cluster has a specific connection and the machines are homogeneous.
Is i... |
I am accessing a third-party API. It requires a key, which is the same key for all of my users. Currently, my application includes that key in the client-side code, and calls the third party API directly. So any user can decompile my code, and get the key tied to my application. (Bad, right?)
I am guessing that I n... |
I'm a .NET developer, currently writing an ASP.NET site hosted on our local servers with Windows, IIS, and SQL Server. We're speaking to a company in India about hiring a developer for a different site, written in PHP but ideally running on the same server: Windows, IIS, SQL Server. He does not know English very well.
... |
One of our products generates vast amounts of reasonably detailed logs into a database table and we're looking to analyse them, possibly build a report from them. Reports can be run on demand, which makes this scenario quite a good candidate for performing the log analysis once and storing the results; the result set w... |
I have a MVC application and a web api. The Web api contain all business logic and the mvc controller has only ui logic.
I want build a web api proxy but I don't know if it's a good idea.
With the web api proxy The controller is decoupled from the name of the action in the web api and from the verbs and dto used in the... |
I'm working at a company on a project for their Sales department. It's my first professional programming job, but I've been coding by myself and learning for years. Part of the project involves taking some data and combining it with input to produce and graph. Then save the data...so on and so forth. So I wrote the cod... |
I am on C++ and using gtest as the main framework. Say I have a edge detection function I want to test that takes an image as an input and returns the edge detected image. I have 3 images ready to be checked.
Is it better to write it in a way that is self contained like
void EdgeCheck(const std::string& input, const st... |
I am trying to convince him in an attempt to produce better code by separating concerns, isolate logic and following best practices.
He wants to produce readable/shareable code but is not entirely convinced that opening it is a good idea.
What other arguments can i use?
|
Please see the code below:
public void GetOffers(List<Offer> offers)
{
if (Validate() == true)
{
OfferFactory offerFactory = new OfferFactory();
foreach (Offer offer in offers)
{
IValidator iValidator = offerFactory.getO... |
I am making a design decision to real time hit API to save all the fields in a form when user make an change even if hes not finished yet. Or, use a save button like most app does.
Any pros and cons other than
pro : real time will generate much more API calls thus heavier server / db load
con : user won't lose any da... |
It's maybe an old horse to beat (not dead yet?), but I'm wondering if OCL allows modeling the problem of the business rules for building houses and hotels in the game of Monopoly within a domain model (conceptual class diagram, separate from an implementation).
I've supplied the rules after my naive attempt, but I'm n... |
Pipeline processing of data can be done either,
using generators only
Example generator in pipeline:
def grep(source, pattern=None):
patternObject = re.compile(pattern)
for line in source:
if patternObject.search(line):
yield line
or
using coroutines only
Example coroutine in pipeline:
@corouti... |
Recently I started a project which didn't seem too hard to make, the concept was a fairly simple application that had to accept input every now and then (maybe 10x a day), and try to perform some operations on them and collect all results at the end. This application would then get a front-end web portal that customers... |
Designing a small API on the side/for fun/for experience. One issue I've run into is URI routing. The issue is:
GET /users/{id} // Get user data
GET /users/availability // Get all users' availability
Both of these map to the same controller@method based on which one comes first in my Routes.php file.
The function... |
General question regarding the STL. Do you guys think that the STL should be used for data structures or would you create custom code? In what scenario would you implement your own code for something that the Standard Library already does? What are your thoughts?
|
Say, I have a code/password like this:
abcde123 --> 8 characters
Where only letters and digits are allowed. How do I calculate the amount of all its possible values? I'm doing this the following way:
1) 26 letters + 10 digits = 36 full alphabet
2) 8 length ** 36 full alphabet = 324518553658426726783156020576256 values... |
Class Book
{
private int year;
private String session;
private int volume;
private int number;
private String khand;
private Date proceeding_date;
private int pageNo;
Book(year,session,volume)
{
$this.year=year;
$this.session=session;
$this.volume=volume;
}
public getBookName()
{
re... |
I have a surveys website. I want to add a feature "level of happiness/unhappiness".
Database schema is something like this:
1) Question
2) Answer options (for some questions single, for some multiple ones allowed)
3) User's answers (question_id <--> answer option id)
Namely, I'd probably need to assign a special co... |
I am writing a C++ applications in the embedded area. A lot of times I think about should I use static or non-static const variable in the functions/methods? Here are my thoughts:
Static constant variable eats memory while the app is running, this leads to a more memory consumption and less memory available on the dev... |
I'm an intern software developer and in my career I've occasionally heard the term 'silo' being used. I've looked into it myself and tried to nail down exactly what it means, but I seem to be getting mixed results. By my understanding, in a general context it means keeping something separated and abstracted away from s... |
I'm working in a team where there are several different OS present (windows, various linux distributions (Ubuntu, Mint) as well as Macintosh). Projects are passed around and we have already come across some issues.
For example the total path length in windows is 260 characters, whereas linux is more relax (though this ... |
From all I read and watch, Domain-Driven Design (DDD), is a costly and time-consuming endeavor. In fact, everyone I have seen, including Eric Evans and Greg Young, say, don't use DDD except where you have a "Competitive Advantage." To find that advantage it kind of drops off into various discussions of business and T... |
I'm writing an iOS app in Swift that calculates a '1 rep maximum' weight using two inputs, weightLifted and repetitions. One of several formulas is used to perform the calculation with these two inputs to arrive at the answer which is the 1 rep max. I'm only storing the input values, not the 1 rep max value. I'm also s... |
I have the following scenario: a client app that consumes a REST API. The client is a mobile application. Therefore, it caches the API data for bandwidth saving and offline support.
With REST it can be done using the If-Modified-Since header. It is, the cache management system from the client side stores the HTTP-Date ... |
I have a hotel entity which has a set of images. I have some business rules which are basically simple crud operations right now. I have heard of repository pattern but working with it I feels like procedural mindset.
Let me give an example, I need to fetch all the images associated with a hotel.
'use strict';
const m... |
I'm in the process of writing a development philosophy document for a small groups of developers (6.5 developers to be specific), but it's ideally a document that will set down the company's best practices as our team scales up. In the process of creating this document I've been interviewing each engineer to understand... |
We use Github and Smartgit.
We are often finding we have lots of "old" branches that clutter up our repos and cause confusion among our Dev team, I can use: git branch --merged for a lot of this.
So I'm seeking to define the rules for safely deleting a branch from an upstream repo, here (in English) is my suggested "al... |
Is there any reason not to build JSON data that can be indexed by some key? For example in the WhenIWork API below, using the user's id to quickly access the data? The reason I'm asking is because it seems that for a lot of uses on the client side you could easily index into the array then and grab the data you need ... |
Without using big int classes in C++, what's a good way to handle arithmetic on large numbers?
For instance, writing a Vector class that deals with dot products and cross products using large doubles can result in non-finite values. Do I leave this up to the user to handle NaN's/(-inf to inf), etc.? Or do I somehow ha... |
I read the first chapters of Clean Code by Robert C. Martin, and it seems to me it's pretty good, but I have a doubt, in one part it is mentioned that it is good (cognitively) that the functions should have as few parameters as possible, it even suggests that 3 or more parameters is too much for a function (which I fin... |
Suppose I have a DAO which touches the DB.
Should the DAO return only data and then it's up to me to do the instantiation or is the DAO supposed to also do the instantiation and return me the instance - and why should I choose one method over another?
// Example with instantiation
studentDAO = {
getById: function() ... |
I seem to have trouble understand the Semaphore implementation.
Q = Queue.
Wait(Process P) {
value = value - 1;
if (value < 0) {
add P to Q;
P->block();
}
}
Signal() {
value = value + 1;
if (value <= 0) {
remove P from Q;
wakeup(P);
}
}
I don't understand why the sig... |
Every day a couple of new javascript modules are created and published around the world and we need to think long term. Let's say today I need to use an ORM module to go smooth and fast. But tomorrow I may face a deprecated module or may find a better one to switch or even may need to create my own.
For example, the te... |
I am designing a treeNode class. While implementing the getPathToParentNode() and getPathFromParentNode() methods, I noticed that their functionality is essentially the same - they just operate on different data structures.
getPathToParentNode() recursively adds all parent nodes into a queue, and then creates the path ... |
I’ve read the answers to Why is Global State so Evil?, and I think the negative consequences do not apply in this situation. However, that’s what everyone says just before they get hit by a falling piano and my software architecture lessons have been a few years ago, so…
We are developing a desktop chat application in ... |
The problem:
Since long time, I am worried about the exceptions mechanism, because I feel it does not really resolve what it should.
CLAIM: There are long debates outside about this topic, and most of them struggle at comparing exceptions vs returning an error code. This is definitively not the topic here.
Trying to de... |
I've gone through a few tutorials in ASP.NET Core MVC, and I've built a little app (for looking at problems in old exams) that looks roughly like this:
Solution
Project
...
Models
Exam.cs
Problem.cs
SubProblem.cs
Views
Exam
Inde... |
I'm having a hard time understanding the b) point from the following statement.
The base of a triangle has a length of 25 cm. Its height is 12 cm. This results in an area of (25 x 12) / 2.
a)What values can be considered parameters for the above statement?
b) Rewrite the statement in a parameterized manner.
c)Which of ... |
Given I have a type we'll call Person defined as
// psuedo code
Person {
Name: string;
Age: int;
Friends: Person[];
Career: Career // black box and assume that Career
// is a type with a few arbitrary properties
}
Given I have two instances of the Person type, we will call p1 and p... |
I have this sequence diagram and want to transform it into a class diagram.
But I don't know if the actor (Customer) is in this case a own class or not. Normally the actor isn't a own class, but in this diagram there are methods performed on the customer...
|
Should a DAO save() method set the id/pk of the instance that is to be saved and return the instance or should it just return the PK?
// Example A: Return the instance
studentDAO = {
save: function(student) {
const id = db.query('INSERT INTO `students`...');
student.setId(id);
return student;
}
}
// E... |
I have a highest-level diagram / map / picture of connected networks where internet is pictured as a cloud, some physical machines, firewall, switches etc which describe an overview of the "ecosystem" / at large scale.
Is there a name for such a diagram?
It might not make a difference that this particular diagram does... |
Context:
This is for a library that reads some old games formats representing 3D models.
Let's call these low-level formats PRM1, PRM2, PRM3 and PRM4.
each of these formats contains the position, origin and primitives of a 3D model
they have minor implementation differences but in the end produce the same type of cont... |
This is an architectural / design question that just came to my mind when comparing current MVC practices in PHP with component based development in Javascript.
My question is:
Why doesn't the view (or parts of the view) define what data should be used to display it?
It seems to be common practice in MVC Frameworks to... |
I've been reading a lot about the singleton pattern and how it's "bad" because it makes the classes using it hard to test so it should be avoided. I've read some articles explaining how the singleton could be replaced with dependency injection, but it seems unnecessarily complex to me.
Here's my problem in a bit more d... |
I have joined a GitHub project which has many different repositories under one user name. My task is to consolidate these repositories into more logical groupings.
Some repositories have dependencies on other repositories using hard coded paths. First, I am wondering how can I determine which repos depend on each other... |
I'm curious to know are there any advantages or disadvantages to creating a named binary format as opposed to an unnamed one? I can only think of a increase in the required disk space.
Roughly speaking a named binary format is a binary format in which you can identify the data parts by using their name (int, byte). The... |
I recently encountered a situation in a Java project where I wrote a block like this:
String user = System.getProperty("user.home").toUpperCase();
user = user.substring(user.lastIndexOf(File.separator) + 1);
final String path1 = "C:\\first\\path";
final String path2 = "C:\\second\\path";
final Stri... |
I want to create a project that can be added as a dependency to other projects in the following languages:
Java,
C#,
Ruby,
Python,
JavaScript (Node)
For example, I want to create a jar which can be added to a Java project, as well as a gem which can be added to a Ruby project, etc.
So to write my original project, does... |
Here are two ways to answer the following question. I'm trying to confirm what I believe their time complexity to be:
If I had a snake game with a x,y matrix of spaces, some of which were occupied the snake, how would I best find an available space to place an apple?
I could run through the existing matrix and store a... |
What do you think about passing typeless maps to APIs (packages, systems, adapters) outer to Core Domain as in 1st Way below?
Strongly-typed objects are inside Domain API, and business rules are using them.
1st WAY:
Domain -> Web API -> Clients
Passes strongly-typed domain objects
Whenever a request comes from th... |
I'm designing a new web application which is powered by a REST backend and HTML+JS frontend.
There's one POST method on it to change one entity (let's call Config), that has several side effects in the state of many elements of the application. Let's suppose the POST is performed this way:
POST /api/config BODY {confi... |
Someone told me that speed is most important for them, so they deploy whatever (to production I assume), fix, redeploy/continuous release and so on. I can't remember exactly, but my takeaway impression is that he thinks it's ok to ship buggy code, if you fail-fast etc.
Is this a "fail-fast" method and what is a good a... |
Let's assume I have access to two rest endpoints, /persons and /products. If I need to retrieve 100K persons with their respective products, what is the best way to do that?
How can I join them efficiently ? Implementing temporary table in DB, joining them in memory? For example, If I do it in memory, then I found mys... |
Assume that I wish to perform an action on a string (e.g., print the string) if, and only if, the string first passes several tests. The tests are diverse (and may even be complex functions themselves), and "passing" a test may mean different things depending on the specific test. For example, some tests can be discret... |
I've been looking into CQRS/MediatR lately. But the more I drill down the less I like it.
Perhaps I've misunderstood something/everything.
So it starts out awesome by claiming to reducing your controller to this
public async Task<ActionResult> Edit(Edit.Query query)
{
var model = await _mediator.SendAsync(query);
... |
I have a tree structure that represents a system of devices that are connected to the PC via serial port. In a way, this structure was inspired by tree model example in Qt and I think that helps to separate logic part from gui. My model has a root node member, and can access all underlying nodes through the root node. ... |
I'm looking at the way UUIDs are stored in MySQL. MySQL 8 still doesn't have a UUID data type, and it still doesn't have custom types, so there are two options - store it as a string or as a binary.
Binary form saves 30% of space and performs much better, in my experience.
Unfortunately binary form is way more problema... |
While generating the SamlRequest xml, what should the Issuer element be specified with?
In the saml docs (https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf), Issuer was not mentioned anywhere under the AuthnRequest section.
But,
If you see the sample AuthnRequest from OneLogin's website - https://deve... |
I was watching a lecture/conference speaker talking about reducing redundant code, when going from Service to Model in an Anemic model vs. the Rich model. But regardless of which I use, I end up with similar to same logic in my classes either way.
Whether I have:
ServiceX.AddName("Johnny");
or
Customer.AddName("Johnn... |
I'm running into an annoying problem at work, where the domain model doesn't fit nicely into the relational model of our Postgres Database.
I have a bunch of primary tables A, B, C, etc. Then there's this other table X, that serves as basically a sub-collection for each of the primary tables. Thus, I want a one-to-many... |
Which of these two is the better way of doing the same thing -
public void someMethod(String s, boolean bool02){
boolean bool01 = s!=null;
if(bool01==bool02){
doSomething();
}
}
OR
public void someMethod(String s, boolean bool02){
List<String> list=new ArrayList<String>();
if(s!=null && bool02){
doSomething(... |
I'm currently in the process of writing an API that will interact with a web application, iPhone app, and Android app for my work. The API is pretty simple and deals with pilots and their availability.
Since I am creating the API and the client-side applications it seems to me that OAuth2 is overkill for this since I ... |
I'm designing an architecture in which I have:
public interface IObjectReader{
public Object read();
}
public class ConcreteObjectReader implements IObjectReader{
@Override
public Object read(){
//do stuff
return new Object();
}
}
Now, if I want to allow a reader to be parameteriz... |
To me a stream implies that I should be able to:
Put things in one end and receive it from the other end in the same order.
Do these things at the same time. i.e. continuously be adding to the top of the stream and reading from the bottom.
The problem is that streams only seems to maintain a single pointer which is ... |
I'm starting a new project and I'd like to plan it's use with git (using SourceTree) before starting. I work as a self developer and I'm starting a project that will have 3 different areas. This is what is confusing me on what should I do to use git properly.
Basically the project will have this structure:
Shared: Som... |
I was looking at a project recently, which contains the following Visual Studio projects:
App.Web
App.Core
App.Infrastructure
The Repository interfaces were contained in the Core project and the Repository classes (implementations) were contained in the Infrastructure project. Why would you put the Infrastructure int... |
With a little googling I could find workflows - which automates the business process - to meet some business needs. i.e.; All I could find is it is a piece of software which allows us to split the process into sequence of steps - and allows us to track each step - also helps us in achieving those steps.
I could find th... |
Imagine this simple PHP class:
<?php
class MyParent
{
// this is our common method, we don't use this method anywhere in parent class
// but we may or may not use this method in some child classes.
protected function helperMethod()
{
// code
}
}
How is it to have methods like top one in our... |
I am working with Java 1.7, IDE is Eclipse Indigo.
I have a base class which has id as an int. It also has a boolean variable onlyIdInitialized; I am setting it to true when an object is created with id.
public abstract class BaseBO {
protected Boolean onlyIdInitialized = null;
private int id;
public Base... |
I have couple of nested resources like Merchant, Hotel, Room. A merchant can have many hotels and similarly a hotel can have many rooms.
Right now for managing these resources I doing something like:
Create
POST api/v1/merchants/11/hotels
creates a new hotel.
Update
PUT api/v1/merchants/11/hotels/42
updates the given h... |
I browsed Wikipedia and encountered a new feature of Java 1.9: Reactive streams.
Unfortunately, the linked Wikipedia page doesn't help much to understand what those reactive streams are and what's so special in them.
It was said they are asynchronous, so apparently there's some kind of buffer. It was also said there's ... |
Here are two object makers I made:
def make_assassination(i):
neighbors = []
def test(graph):
for n in graph.neighbors(i):
neighbors.append(n)
graph.remove_edge(i, n)
def reset(graph):
for n in neighbors:
graph.add_edge(n, i)
retur... |
Disclaimer: I think about the agile values a lot, and happily support them.
After almost 20 years of "non-agile" software development projects, and a couple of years in Scrum and alleged "XP" projects, I'm sorry to say that:
the non-agile projects worked out pretty well (they were <= 1000 man-days, small-ish teams, ~3... |
I'm building a system using redis as a pub-sub system.
I'm thinking about ways to represent multiple groups that clients can subscribe to. I could do this with one channel per group, but this could lead to a vast number of channels on the redis side and multiple subscriptions from each channel.
Alternatively, I could p... |
Can a use case be both an extension and an inclusion?
|
I see and work with a lot of software, written by a fairly large group of people. LOTS of times, I see integer type declarations as wrong. Two examples I see most often: creating a regular signed integer when there can be no negative numbers. The second is that often the size of the integer is declared as a full 32 ... |
I am developing a server that exposes multiple services to other processes (they could be both servers or hmi clients): those could be hosted on the same machine or not and they could be written in multiple languages (java, c++).
I would like an advice to choose the proper protocol (or protocols) to expose the services... |
I have seen few projects where access to many system-specific functions was wrapped into the project-specific intermediate layer. Examples included functions for logging (wrapped around Log4J), file IO (methods like write content to the file, catch IOException), resource access, using properties and things the like. Mo... |
I had a friend who said:
Docker is amazing. You can use it to replicate production and all its quirks on your local machine. Then you can deploy that instance straight through all the staging workflows super-quick.
Now this would be true if the developers were writing Ruby, PHP or Go - where there was a direction bin... |
Let's say I want to make a webshop, which sells custom mugs (for the sake of simplicity). In the shop, you go through 3 steps:
Select cup size
Select color
Add a logo
And then finally it is added to a basket, which then leads to a check out procedure. That means that there, at some point, will be a class Order, which... |
I'm currently exploring BDD test frameworks like cucumber and I find it curious when people say
since the feature files are in simple natural language it improves
clarity and gives a clear vision
but, isn't natural language the cause for most of the trouble we have in software Engineering?
Natural language is amb... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.