instruction stringlengths 34 36.1k |
|---|
I'm looking to improve the readability of a lengthy C++ function. This function contains a number (> a dozen) variables that are used throughout. The main logic of the code is a long list of condition checks (sometimes nested, sometimes with loops) followed by various actions. Because of the lengthy number of lines det... |
I am new to Scrum and I have been reading the book of Kenneth entitled "Essential Scrum" and I have some doubts regarding the poker planning.
I understand the mechanics of the game, and for what I see the number that is in each card could represent the "approximate" number of ideal days that a user story should take; i... |
Is it ok to add deferred assertions like this
var actualKittens = actualKittens.Select(kitten => {
Assert.IsСute(kitten);
return kitten
});
Why? So I can iterate just once even with statements expecting materialized collection for example:
CollectionAssert.AreEquivalent(expectedKittens, actualKittens.ToList())... |
I recently had a discussion where we argued if it is a good idea to make everything const if possible.
The argument did go like that: If I expose an internal part of the class by returning a non-const reference to it, I should not make that getter const even if it is possible.
For example:
class Foo
{
std::un... |
At work, a 3-layer-architecture is the go to whenever a web application is needed.
I don't mind this, but many of the applications we start, do not seem to have an initial need for this. These applications are pretty much just a user interface to the database. This results in a ton of business logic that just sends th... |
When developing a many-to-many relation I create 3 entities: Car, Part and a CarPart which contains the lists of both entities.
On the client-side of the application I want to be able to directly access all the Parts of the Car without the need to use the many-to-many objects, to accomplish this I use the AutoMapper li... |
Currently I'm using logger in my project in the following way :
private static final Logger LOGGER;
static{
LOGGER = logger.getLogger();
}
I got a code review for using static block to initialize the logger variable. I was told to intialize the logger variable in the declaration statement itself.
private static fin... |
I am starting a new project on which I am making a reservation system as a PHP/ MySQL web application.
Basic functionality should be:
admin can add default appointments (several pro day)
users can attend the appointments (with a by admin set max).
Currently I'm figuring out how to make the database structure.
I was thi... |
This looks like another network's question, but I think it fits better on here rather than StackOverflow, since it's not gonna have one basic answer.
We are in the context of iOS development, I'm trying to simplify the use of UITextfield. More specifically, let's say this is an "Amount" textfield when wiring money in a... |
(Note: I'm not sure how to frame the question properly, so please feel free to edit it or comment about how I can improve it.)
I guess this question, while covering a fairly wide scope, is pretty limited to statically typed (object-oriented) languages (I'm using Java in particular) for implementing CQRS and Event Sourc... |
You have a server that sends the client data. A JSON object.
{"name": "folder1", size: "2406"}
The client updates it's data:
data = newData
And the client is updated. Reactive frontend coding as usual.
However the client needs to keep it's own state. It also has isOpen for that folder. So it's object looks like ... |
In a Java/Spring MVC/Hibernate application I have model objects that contain references to other model objects where the database has foreign keys. So for example, I might have:
@Entity
@Table(name="branches")
public class Branch {
@Id
@GeneratedValue
@Column
private int id;
@Column
private St... |
Note, presently have no experience composing or modifying C++ code, which the code that will need to compose or modify is written in.
Specifically, window.speechSynthesis.speak() does not currently provide an option to return the audio generated by the function call as a Blob, ArrayBuffer or AudioBuffer at either Chrom... |
I am building a software where UI, Business Layer and Data Access Layer are tightly coupled in a single tier.
I want to decouple layers, because a change in the database can cause the change in my presentation layer.
Is it a good practice to always decouple the entity classes from the presentation layer by implement... |
When I start a new project, I tend to look at other people's source code who have implemented the same project. This gives me an idea on how the overall project is supposed to be created and the basic flow and the implementation logic of the program.
The problem with this approach, I feel, is that I am not thinking fo... |
I see code like this sometimes (mixed PHP and JS in this case, but could be any server-side language):
<script>
var data = <?php echo $bigDataStructure ?>;
// then lots more pure js with no php mixed in which can access the data variable
</script>
Which seems like an appropriate way to pass data from a server-side... |
I am studying Domain Driven Design and was introduced to the concept of Onion Architecture, which uses the terms of Core, Domain, API, and Infrastructure.
I am from Java background and am familiar with and typical project structure (legacy MVC pattern) configuration, model (both value and entity), repository, service,... |
I have been familiarizing myself with Googles Security Design Whitepaper. As far as I can understand, and with respect to a Micro-services architecture, from the Access Management of End User Data section, Googles authentication scheme works as follows:
User authenticates with the "Central User Identity Service" and i... |
I have just a basic site with registration. With all other data, it stores the registration date in MySQL. If I'm in USA or in Canada, and I register at 2017-03-07 (Y-d-m), in MySQL it's 2017-04-07 because we have 10 hours time difference. So if I want to display the date in my site, it says that it's happening in futu... |
I'm trying to build a project using the clean architecture, as described here. I found a great article on how to do this in Go.
The example is a very simple one, and the author puts their code into packages named based on the layer they are in. I like Uncle Bob's idea that an application's architecture should clearly c... |
Design 1: For a web application. In the past, if I insert a record/data in UI, I will save this new data to the database, then the UI will be reloaded (like clicking browser refresh icon), but this UI reloaded action will query the database again to fetch all data into UI. I know this will slow the web application perf... |
I write code while traveling, and I almost always use cafe (but sometimes on a room in AirBnB).
However, the problem is that too often the Wi-Fi at cafe is awful, either too unstable to keep connecting, or too often to get a server error. In many times I even could not connect to the Wi-Fi.
Another painstaking, yet mo... |
Note: When I used "complex" in the title, I mean that the expression has many operators and operands. Not that the expression itself is complex.
I've recently been working on a simple compiler to x86-64 assembly. I've finished the compiler's main front end - the lexer and parser - and am now able to generate an Abstra... |
I recently had a discussion with a coworker about network timeouts. This person wanted to have 1 second timeouts because they believe the optimal user experience is one where the user doesn't have to wait long before knowing if something fails. However, at scale 1 second is far too short to cover the range of network c... |
In an android project, I don't see how the following architecture can be considered MVC.
The team said:
Android apps are fundamentally MVC
the Controller is the Android Activity.
the MVC View is the Android View.
This does not look like a correct MVC architecture to me,
so I disagreed because:
they handle input ev... |
My current .NET project looks like below:
Solution (.sln)
--BusinessProject A (.proj)
--BusinessProject B (.proj)
--DataLayer (.proj)
--A separate project calling ExternalService 1 (folder)
--A separate project calling ExternalService 2 (folder)
--A separate project calling ExternalService 3 (folder)
--A sep... |
System model has Workflow container class, instances of which may contain subclasses of the Node class, specialized for different behaviors (eg, Initial, Intermediate1, Intermediate2, Final). There are other classes Node classes use as a context, eg, User and Content (which can have Workflows of different kinds), but t... |
I have an API endpoint that returns some statistics. Currently the response looks like:
Option 1:
{
"stats": [
{
"name": "some-stats-key1",
"value": 10
},
{
"name": "some-stats-key2",
"val... |
I am using dependency injection on a project to inject services using Unity dependency injection
private async Task<T> GetResult<T>(HttpResponseMessage response)
{
if (typeof(T) == typeof(byte[]))
{
return await(response.Content.ReadAsByteArrayAsync() as Task<T>);
}
else ... |
Hello fellow Software engineers,
I've been doing a lot of research on microservices these last few days and have come across a great deal of articles and videos explaining the concept, programming models and things alike.
Now I am tasked with designing a platform that offers microservices and I've run into a snag. I ha... |
I need to build a small website for my ops team that will have a series of iframes pointing to a couple of Kibana graphics. The website will have, lets say, 4 links, each pointing to a a specific website page with X iframes in each, with different iframe URLs.
The thing is, I don't want to statically type in the URLs a... |
I know that McCabe basis path testing ensures that all linearly independent paths are tested, making sure that all code branches were covered in an effective manner.
But nowadays, I doubt anybody designs tests from the source so I am thinking whether this can be used on a higher level, e.g. general flow of an applicati... |
Background
In a typical Model-View-Controller application using a database to store the model, the consensus seems to be that lookup tables are a solid design decision for enumerated types. Although some DBMSs support ENUM types--a more straightforward solution--people cite disadvantages like "data not being treated as... |
Please see the code below, which I took from Jimmy Bogards wicked domain models:
public Offer AssignOffer(OfferType offerType, IOfferValueCalculator valueCalculator)
{
DateTime dateExpiring = offerType.CalculateExpirationDate();
int value = valueCalculator.CalculateValue(this, offerType)... |
What's the difference between "to" and "as" method name prefixes like
toList(),
asList(),
etc...
When to use which when designing a method?
|
In order to have make sure all code eventually goes through pull request code review, we've started creating branches for features and bug branches off of develop following the git-flow style.
The only problem is that once a bug is found in a release branch, we often have to make a branch off of the release branch in o... |
How do I construct a system that has all of the following:
Using pure functions with immutable objects.
Only pass into a function data that the function it needs, no more (i.e. no big application state object)
Avoid having too many arguments to functions.
Avoid having to construct new objects just for the purpose of p... |
I don't know which methods should be public, because I have the test methods which require a node and a node is something which no one must know about.
public static class Node<K, V> //nested static class of AVLTree
public class AVLTree<K extends Comparable, V>
public void insert(K k, V v)
private Node insert(Nod... |
I'm using an Java Servlet (with embedded Jetty, no Spring, no frameworks) and I'm adding asynchronous processing and caching to it. The exact implementation is irrelevant to this question and it's not very Java-specific. My problem is the overall code structure, which before the additions looks like this pseudocode
voi... |
So I've gone through a few tutorials on writing .NET Core MVC Web apps. I think I've understood the flow from routing a request to the controller (with the EF-dbcontext injected into it) manipulating the dbSet model and onward to the view returning a response to the user.
I've been writing a little personal app to und... |
In the title, with namespace-related elements, I refer to Enums, Delegates and other elements that do not belong to a single class, but to the whole namespace, or application.
I know that I can cram these into the namespace just about anywhere, for example, if I use WPF, I usually put them into App.xaml.cs, so that I a... |
I have data for a certain domain distributed between a microservice and a legacy database. I have a search which spans fields on both legacy and microservice database. Previously (before microservice split), it was done with 1 sql query. Now I need a REST call and a query to legacy database to serve this search functio... |
We are a small shop and focus on web development. We have a website that users need to login.
I want to outsource the "app" development by getting someone to build the app and packages for android and ios - but basically our website will be the application.
We've done a test that works fine, but the user lands on the ... |
Agile requires the correct level of documentation, not too much or little, no "good luck" statements (I can't remember the SO question that used this.)
So if you are writing User stories and the like, how do you start out in the initial negotiations? You don't just write a contract or statement or work that says, "Bui... |
All of the enterprise projects I work on seem to follow the same pattern.
A request is issued to the server (from a client or Api)
The server side loads some data from a database
Modifies the data in some way
Commits the changes to the database
E.g.
//Client after user click cancel on the order screen
_apiClient.... |
In Think Python 2e "class" is defined as "A programmer-defined type. A class definition creates a new class object."
But isn't a built-in type considered a class too?
Using Python 3.4.0, the following code:
class File:
"""Represents a computer file."""
...
print(type(str))
print(type(File))
print(type("Mahmud"... |
I came across it in this article:
You call a method and pass it a parameter that doesn’t affect its control flow.
This is still coupling, but we’re starting to reach the kind that
isn’t so bad. Sometimes you need parameters! If you wanted to remove
all coupling you wouldn’t be able to pass data between objects at ... |
Most of the groundwork for coroutines occurred in the 60s/70s and then stopped in favor of alternatives(e.g., threads)
Is there any substance to the renewed interest in coroutines that has been occurring in python and other languages?
|
In my current software engineering course, my team is working on a library management system that is essentially a command-line/REPL environment with a half dozen commands, e.g. checkout, search, etc. We've elected to use the command pattern for this, so each command will be represented as a class. Now, there's the que... |
Alright....so this is driving me nuts as I'm trying to encourage the team to write more tests yet here I am unable to determine whether the following example is considered an integration or a functional test case.
Consider the following:
We have a simple web application which routes/exposes a number of JSON feeds. ... |
I have asked a similar question before, but I still struggle to 'get' this.
I have a bounded context that is UserManagement which contains all the details about User, UserId etc. This is separated as a context as it is useable in two separate applications.
I have another bounded context that stores all the reusable cod... |
I want to tag the values of variables with a "quality" attribute that can be changed dynamically during my programs execution. My first thought was to abuse the standard attribute functionality by tagging the value with my custom quality attribute. EG
[QualityAttribute(Quality.Bad)]
int value = 0;
...
value = 1;
(** s... |
I am currently working on a Web Application. One of the objectives is to use the MVP (Model View Presentation) Design Pattern. We would like to use WebSockets to communicate between client and the server.
My question is: Do I have to put the code for WebSocket handling in the Presentation, or would it be better to put ... |
I have just started to study about computer systems and I came across this line. How can the difference in the contexts in which we view data objects make this happen?
Bytes store numbers, now that number represents something, a symbol or a character or something else so how can the same sequence of bytes represent dif... |
I have a Mandelbrot Set explorer project that I have hosted on GitHub. I used it to learn how to generate the Mandelbrot set, and to get more experience with using the Java ExecutorService. It works great, but I've just been tacking on new pieces as I go along, and it's becoming a mess. It's already broken twice after ... |
I'm a Network Engineer and I'm learning software developing in my spare time. I have some doubts about some OOP concepts. I'm trying to get an understanding of what is the difference when these terms and phrases are used.
When one is asked to instantiate a class, is this another way of saying create an object for that... |
Let's start with a loose definition of 'marker interface' (please correct me or dispute this if you disagree):
If applied to a type, a marker interface doesn't provide any contract
of methods to implement for that type. A marker interface gives
semantic meaning.
So, OK, that's fine. However giving something a mea... |
What are some best practices for writing memory-efficient (for the lowest peak memory usage) CSS? I realize this is a broad question, so I have broken it down into two main categories:
What are 'do's and 'don"t's regarding which CSS properties should be used for what things in what circumstances for the smallest memor... |
When designing a RESTful API, should your URI map to tables (for the most part). I have 2 tables that look like this:
Users
+-----------------------------------+
|id|first_name|last_name|email|role |
+-----------------------------------+
|1 |Jonny |Walker |a.com|User |
|2 |Jim |Beam |b.com|User |
|3 |J... |
I have to perform a number of 'housekeeping' tasks that need root access (Linux, Debian). Generally one time only, but I do need to check that they have been performed.
I don't really want to run the whole program as root though. Is there a good pattern to do these tasks without having the whole program as root?
The ta... |
I am using Python's peewee ORM to map my relational database, but I'm noticing that my models are starting to get bloated and I also seem to be violating separation of concerns.
For example, my User class has self explanatory methods such as
authenticate()
push_message()
upload_image()
Even though it's useful to call ... |
I'm planning a database which will contain data for many projects / customers.
Data for each customer will be totally independant. However they will all have the same structure.
So I'm wondering, could making a schema for each customer (and duplicating tables in it) be a good option ?
To resume, I ponder between the t... |
My application interacts with an external system. There are multiple request-response interactions for a single business case. This information (request and response messages) is also logged in MongoDB. The structure is similar to:
{
_id: ObjectId("..."),
caseId: "PRC-122",
msg_date: ISODate("2017-06-10T11:21:41.112... |
I am supposed to design the tests for state machine software. I have covered all states and all transitions. The last step is to detect the hidden states (states that look the same but internally might be different, e.g. overflown buffers) using the tests designed with characterising set W. I have no idea how to determ... |
I've been working in an app that handles relations and constraints in application level.
How would this affect changing databases while keeping the application software?
This would mean the database would just be 'Data persistance as a service'.
How would this affect decoupling, modularity and orthogonality?
|
In many years of OO programming I've understood what discriminated unions are, but I never really missed them. I've recently been doing some functional programming in C# and now I find I keep wishing I had them. This is baffling me because on the face of it, the concept of discriminated unions seems quite independent o... |
I have two type of entities: User and Resume. So my instinct said me to write two controllers.
UserController endpoints:
/users
/users/{id}
/users/{id}/resumes
ResumeController endpoints:
/resumes
/resumes/{id}
/resumes/searchBy[?criteria={criteria}]
User has a reference to resume, so to create one I do a POST to ... |
I have a requirement that is a user of the system can make a complaint about an organization and then the admin can blacklist that organization. Do I have to include the use case "Make complaints"(of user) to the use case blacklist(of admin). Please help me with this matter.
|
I have been reading a bit about Kanban and I am slightly confused on the topic of Requirements.
In my current project we use Scrum. At the beginning of a Sprint, we have a session where the BA does a walkthrough of the Story and describes it as best she can. We then take the story, review it, discuss it and prepare a ... |
What are the best practices regarding start of an application which depends on several services and maybe some file system stuff like mounts, directories or config file.
Let's say the dababase is not up or returns a fail status when the application starts. Should the application:
fail to start and report this error or... |
I would like some input on some refactoring I am to do on a mobile backend (API).
I have been tossed a mobile API which I need to refactor and improve upon, especially in the area of performance.
One (of the many) place where I can improve the performance while also improve the architecture is how the backend currently... |
This is always a problem for me. Say, in a game, there's a class representing an enemy spacecraft named EnemySpacecraft and there's a class representing some collection of those, say all that exist in the game. This class may be implemented as just an encapsulated array of enemy spacecrafts. Giving this class a name li... |
What's the needed math for building algorithms? Because I was reading a book and I can't understand much. It says I need simple math from high school.
I don't want to learn all the math that exist because I hate math, no that much though. What math is actually required?
|
I have the need to match incoming fragments of semi-structured text to previously encountered fragments.
The most text fragments are sized ~200 to ~4000 characters and contain both human-readable text (a few sentences at most) and machine-generated text - string and numberic codes, IDs, URIs etc.
I've used K-Means clus... |
How can you know if something is "pure CRUD solution" ("just CRUD")? It seems complexity is a hard thing to define for the various DDD proponents. Everyone says if it's "just CRUD" you don't need DDD. What does "just CRUD" mean? Every application I've made has CRUD operations somewhere.
I realize there are differen... |
I've made a small change to an integration component and have prepared unit tests to cover my work. All new and existing unit tests are passing.
It will take a substantial amount of time to configure and run the component locally as I will need to restore databases, check firewall rules etc.
The definition of Done in t... |
In short, this question is about the cross-browser-compatibility-ness of a way to serve a HTML page as XML. I am interested in serving a web page as XML to be interpreted as HTML for increased CSS performance by removing the user agent style sheet. The reason for this concern will not be explained as it already has ca... |
I have a Hotel entity which can have many address and many image objects i.e. they are one2many related with the hotel.
The question arises while fetching and saving the linked resource.
Fetching
I load the resource which is Hotel here which has the ids array of the address as well as image, these address contains the... |
Lets say A, B are classes then what does this UML diagram mean?
(1) A contains B
Or
(2) B contains A
I'm confused as to which direction the aggregation holds.
|
Say I have a LINQ query like this:
application = CreditDatabase
.Applications
.Select(Mapper.Map<Application>)
.Where(c => c.uID == urID)
.DefaultIfEmpty().First();
It returns null if the LINQ query returns an empty result... |
I am trying to implement the following pattern in a Cache layer.
I'm splitting the implementation of possible Cache methods such as getUsers() in UserCache Class, getLikes() in PostsCache class.
But I'd like all these methods to be accessible from a Single class object such as Cache.getUsers() , Cache.getLikes()
The re... |
I'm starting to learn more about software development, I'm still learning it, so some things are still difficult for me. Also, just to put in context, most (or basically all) of my projects are online projects (WebApps, e-commerce, crm, etc ...).
I was reading more about how to plan a project before starting it but I h... |
In this post, there is:
For example, with your own persistence model, you are not able to
benefit from the built-in change tracking functionality. And that
means you will not be able to implement reliable domain events – the
ones which get fired only when a transaction gets committed to the
database. You eithe... |
Pure functions are known to facilitate parellelizing.
What is it about functional programming that makes it inherently adapted to parallel execution?
Are compilers such as Javac smart enough to detect when a method is a pure function? One can always implement classes which implement functional interfaces such as Funct... |
I'm in the early stages of developing a game engine in C and so far I've been using a simple logging module to print error messages to a log file. For every possible error that could occur, I have prepared an error message that includes the file name and line number. This is all done using preprocessor macros so I can ... |
I've been looking for a good way to style a react component just using css stylesheets. I would have used style-loader, because it's as easy as require('./style.css') and allows to save the final styles into a stylesheet file for production, but... I'm trying to make a shareable react component (I will publish it as a ... |
I'm looking for perspectives on how risk analysis is performed when there's not precisely a "dollar value" associated with the risk, as in an Open Source project. Traditionally, risk analysis takes the form of
Asset Value X Annual Probability of Loss X Probable Outcome of Loss = Risk
Open source community driven projec... |
Say I have a function whose first parameter is used differently depending on how many arguments are passed. In this case, it is easier to just process the arguments object as a whole within the function definition instead of giving the parameter an explicit name to deal with that could be semantically incorrect dependi... |
How do you determine when and where to use a for loop in programming?
|
I have been using AngularJs since a long time. Me and my team makes heavy use of services for retrieving the remote resources like Users which intern uses $http service so, basically, for each entity, I have services which fetches/stores etc that entity.
I was thinking why not the entity itself should be able to do tha... |
There is a plethora of tools available for engineers to test their code these days. However, frameworks like Mocha.js came around only in 2011 with the ascent of NPM. So I wonder what were the practices around software design a few decades ago?
|
So far I have used to write interfaces to those classes I want to mock/fake. Reason for that is that those classes don't have any virtual method to overwrite. But resently I have figured out that I could use virtual methods also.
When should I use virtual methods rather than interfaces?
Should I even make most of meth... |
I am trying to build a mobile application (Android/iOS) and the app will require a lot of back end operations.
After doing some research I noticed that several developers recommended using MBaaS services only if the back end operations are very simplistic however since I have little experience using these tools I had t... |
Please see the Rules Design Pattern on this webpage: http://www.michael-whelan.net/rules-design-pattern/. It has classes like this:
public interface IDiscountRule
{
decimal CalculateCustomerDiscount(Customer customer);
}
public class BirthdayDiscountRule : IDiscountRule
{
public decimal CalculateCustomerDisco... |
I am working on a number of maintenance projects and I always include requirement/issue number/code in the the comments whenever I am adding or changing code. In such way I provide traceability from requirements to the code and back. My experience is that such effort can be of really great help for furhter maintenance,... |
I'm getting familiar with an existing Akka.NET codebase and the actor model itself, and I notice a number of actors are configured to receive empty messages and do their work.
class Invoke
{
}
class MyActor : ReceiveActor
{
public MyActor()
{
Receive<Invoke>(i => /* do work */);
}
}
The use of a c... |
I know we can use the Mediator Pattern to communicate between view models but what about views?
Lets assume I have a button in View A which should trigger functionality of View B. How is this preferably done? I could use the Mediator but it seems more like a hack.
Here is a thought of mine:
|
We are building a system where we accumulate data from many of our internal services, process them and generate set of data called Jobs saved to database. Our client application running on client systems periodically requests for these Jobs and eligible Jobs for the requested client will be sent in the response. For ea... |
This question is about the architecture approach.
How would someone go about creating the immutable state for a graphics editor that would eventually provide an "undo/redo" functionality, considering that the library for canvas manipulations already has its own state management.
I am not sure that I'd be doing the righ... |
Consider the following application structure.
The scraper class extracts the necessary information from a page, and I want to save it to the DB.
The ORM class is a wrapper around sequelize.js. It establish a connection to the db, loads the models, synchronizes with the db.
app.js inits the ORM, then the Scraper class.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.