instruction stringlengths 34 36.1k |
|---|
I'm developing a new service in a micro-services environment.
This is a REST service.
For simplicity, let's say that the path is:
/historyBooks
And the POST method for this path creates a new history book.
Let's assume that a history book covers one or more eras in history.
For brevity, let's assume we have only the fo... |
Assume we have the following class:
class Foo
{
public:
void func()
{
_func1();
_func2();
}
private:
virtual void _func1();
virtual void _func2();
};
This class, from one side, specifies the interface (foo method), and, from the other side, it defines the implementation (first we call _func... |
I couldn't come up with better title. I will try to explain what the problem is.
Currently I am trying to build dynamically created report structure. I define needed report in config file. When user wants to a report I simply parse from config and create. The struggle I have is about how I can implement a general struc... |
Is it a good style to place curly brackets around logical parts of sequential code to structure it?
An advantage would be, that you can collapse these blocks in an editor like vim and get a better overview of your code.
I talk about code, which does not belong in a separate function, due to parameter passing overhead, ... |
I have a repository, which at the moment, reads from the database every time it is called. However, the data is only updated once a day, and to improve performance, I'd like the repository to store the data in memory.
When the data is updated, by another application (but same solution), I would like to notify the repos... |
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. Ie your software stack becomes an immutable repeatable widget in a CD pipeline.
The challenge is that the understanding the docke... |
Why is Iterative software development better than Waterfall software development? In the Iterative method it take more time because of iterations and start with minimum small planning which is not good because with minimum planning which can easily lead us to wrong path.
Instead if we use waterfall method first we wil... |
For various reasons we are looking to move from TFS source control to Git. We're hoping to keep our current workflow but struggling to understand how this translates to Git. In TFS we typically have two branches:
Main (day to day dev in here)
Release (production, we deploy from here)
Typically, developers will check-... |
I should preface this by saying that although I've been programming for a while, this is the first time I'm doing it for work and am relatively new to PHP.
I have been asked to create a PHP app that, on the face of it, is quite simple - although it has some complicated business logic. Basically, it shows the user a num... |
Current setup
We currently have one Jenkins server that automates deployments for about 15 different Java web applications. Each application has three deployment environments on separate Linux boxes.
Development
Test
Production
In Jenkins every application has it's own "view". Inside every view there is a job for ev... |
The are two operators '<>' and '!=' used in programming languages with the same general meaning.
'<>' can be used in PHP, SQL, and Pascal.
'!=' seems to be more commonly used.
What is the original reason for both of these operators to co-exist, when they seem to be so similar in purpose? What was the first language to ... |
I'd like to better understand Iterator/Range design decisions (focusing on InputIterators).
Basically, this is the java model:
while (iter.hasNext()) {
Object o = iter.next();
// do something with o
}
But, here is a quote from James Kanze:
Not that Java's iterators are perfect, either. The merge access and
... |
I am curious on if this design is considered good or bad practice.
I have a dispatcher and a service class.
Dispatcher I have the following:
public void doBeforeUpdate(Map<Id,sObject> oldMap, Map<Id,sObject> newMap, List<sObject> triggerOld, List<sObject> triggerNew) {
Boolean myBool = service.myCheck(triggerOld... |
I recently started reading theory behind algorithms.
I then started thinking about "what if we abstract problems and algorithms, so you would be able to implement a generic system that can solve most problems.".
Unfortunately I was not able to find information on this topic. Logic Programming comes pretty close I guess... |
I have been researching oauth2 as of recent and trying to draft an implementation plan. However I seem to be missing something, or something hasn't quite clicked yet.
I plan on creating an api and having certain endpoints be protected, requiring authorization. This api will be accessed via my 1rst party web applicatio... |
Suppose that I want to build a notification system in which users can configure what time during the week they will receive notification.
So I might want to get notifications on
Monday 10 am - 2 pm and
Thursday 8 pm - Friday 8 am
something like that. But would the object be like?
I am thinking
class TimePeriod {
D... |
I'm creating a site for commercial needs, for myself or for sales. In them, I'll use the Laravel framework. Laravel is licensed under the MIT license. The MIT license tells to me:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
What is the... |
How exactly do stack machines (both real and virtual stack machines) store global variables?
I know that C(++) just compile it to the .data segment of a program's memory segmentation.
Then there's Java's JVM which uses a stack-heap system (both data-stack and heap are stacks that grow towards one another) and stores st... |
Scenario: I am designing a system where user uploads a structured data file ~0-5GB in size. I need to let user analyze this file and perform some transformations on the file which essentially means running functions that extract information from this file and/or change structure/data in the file. User can perform these... |
I'm reading Code Complete (2nd Edition) and in Chapter 21 the author mentions the terms system code and application code in the context of formal inspections, saying that system code has to be handled at a slower pace than application code in order to be productive.
I've tried searching the web for a distinction betwee... |
I'm looking for pseudocode suggestions for sorting my mp3 files in a way that avoids title and artist repetition. I listen to crooners - Frank Sinatra, Tony Bennett, Ella Fitzgerald etc. singing old standards. Each artist records many of the same songs - Fly Me To The Moon, The Way You Look Tonight, Stardust etc. My go... |
Python (Flask) web application has a big portion of email/SMS messages generated by templates, translated by Flask-Babel.
To my eye, having literal constants for the message in views, among other view logic and calls to the other layers, is not elegant: Views are there to render the html or serve ajax calls, not render... |
In the book Compilers: Principles, Techniques, and Tools (2nd Edition), Appendix A, the authors offer a implementation of a compiler front-end that generates three-address code for a very simple language.
Like many other languages, the language in the book has scopes denoted by opening and closing curly braces. To avoi... |
On my team I'm working as a frontend developer in a React codebase. We're building an application and do everything in React. Before this I was actually always a backend developer. Now I have the feeling that in most "backend" frameworks it's quicker to just generate a view with a template engine instead of connecting ... |
I'm the co-founder (there's two of us) of a software development company, doing mostly webdevelopment. Recently we hired our first employee and soon enough we find ourselves in the need of a standard (and preferably enforced) coding style. We do however not enforce a certain IDE. I for example use Atom while the curren... |
I'm looking for some advice on testing strategies for service to service communication.
I have one service (service A) that makes a call to another service (B) - which is a rest API. Both services are owned by me.
I have some unit tests around the service calls and I simply mock the HTTP library so no requests are actu... |
I have recently tried to to implement unit tests on a Java Web Application my project is built on MVC design architecture and uses Spring & JPA Hibernate and JSF here is a package tree
-src
-entity
-dao
-impl
-service
-impl
-rest
-impl
-web
-utils
-config
-common
-enums
-exceptions... |
I'm in need of some advice before going foward.
I want to build several large scale projects, like a marketplace product, and a few domain-specific products and libraries. The products may or may not be related but may share libraries. Each product may very well be their own companies [e.g. the marketplace]).
I'm for u... |
For small command line applications I can get away with simple command line input.
./test input.png output.png
But for larger applications that requires a lot of input, simply using command
line becomes messy very fast.
./test cam1.png cam1_focal cam1_principle_x cam1_principle_y cam1_k1 cam1_k2 cam2.png cam2_foca... |
I'm working on a application which is implemented using microservice architecture. There is an authentication service (A) which uses jwt standard, and there are other services in the application like S1, S2, S3 and so on.
Now for example S1 receives a request, it should validate the token to see if the user is authoriz... |
There is REST endpoint in my application which handles POST request and then makes a HTTP post to another external application and when the resource is creating in the external resource then I create a record in my database with the externally created resource ID.
For example if a user requests to save a new Car then t... |
I am noticing a weird mentality, when it comes to refactoring code, and I am not too sure about how I am perceiving it.
Overview of the current project:
A web application used as an extension to an existing 3rd party web application. The 3rd party application maintains schedules between customers and vendors. The exten... |
We are developing a REST application based on an MVC architecture.
The service layer is returning Optional<T> where T could be any class.
So on the controller layer there is a conditional statement which tests if the result is Optional.empty, and then return a custom response with data []; else, return the actual data ... |
Below are the relevant types(in java) for annotation processing,
In addition to Field & Method types, Package type is also used in context of annotations with reflection, because these types implement AnnotatedElement interface.
This contract allows to access(in runtime) the instances of those types to get their meta... |
I may be misusing "scheduling" in this context, but here it goes:
I'm trying to build a simple calendar scheduling algorithm/routine, the purpose of which is to determine if a particular Time-Span is long enough to execute a number of scheduled events, each of which having a pre-determined duration.
I.e.
Task A, Durat... |
I currently have a web server running apache with multiple sites on it using virtual hosts. I want to add a service to my server that is using nodejs but I want it to be accessible under the same domain as a sub-domain. This is, I believe, impossible with my current setup since nodejs and apache can't both listen on po... |
Currently looking into Event Sourcing in a Microservices architecture and I've found this article. It describes a possible implementation of CQRS and event sourcing.
If the logic dealing with updating the read model and creating the events are both implemented in the same (scalable) service, how does this architecture ... |
I have heard from a former colleague that not all bugs need to be fixed, because as you go down the priority list of bugs, the use case which causes that bug becomes more obscure, or the customer satisfaction gained gets lower. But you still have to spend considerable time on fixing that bug.
In an effort to convince ... |
When trying to turn a class with mutable state into an immutable one I am regularly having a hard time choosing between two alternatives: I can 1)
either extract the state into another (immutable) state object and
pass this state to the class with every method call (and return the
new state) or 2) make the state part o... |
I am trying to break down a large application so that multiple teams can work on it. I have created a number of Bounded Contexts for the domain layer. Each bounded context is contained in its own solution with an Infrastructure layer and a Service Layer. There is one repository per aggregate root.
How do you deal wi... |
Sorry for the long-winded question. I hope the question and its potential answers can serve as a useful example to developers who are wondering where to set the bar regarding testing fairly simple combinations of already tested functions.
Consider the following simple model for an order (definition of auxilliary types... |
I know that there are some differences between GET and POST, like descriped in this post on StackOverflow. But what I cannot figure out is, are they interchangable, assuming that you change your code accordingly?
For instance, could you use POST to request HTML-content and display it in the browser? I am not concerned ... |
I am going to log some events happening in my program. My program is working on a database that I cannot change (add table). These events can be stored in a single table with no relations.
I would think, that since there are no relations, an SQL database would be a poor choice, but I am not familiar with other types. T... |
I was re-learning about state diagrams this weekend, and realized that I may have been using them for years without realizing it.
Suppose i have an order record, with a bunch of fields including status, start date, end date, customer name, address, name, etc.
The status field has different states, and needs a transiti... |
We're having a bounded context dealing with payments.
I'm trying to model case, where Merchant can create another merchant and inherit some of its properties in this case: users that are needed for authentication to another bounded context (payment processor) that acts as open host service with anti-corruption layer o... |
How should an open source project with a public repository best handle pull requests (PRs) that address securely reported but not yet publicly disclosed security vulnerabilities?
I'm involved in an open source project with several hundred contributors. We publish security notices and vulnerabilities several times a yea... |
Our database has an Attribute table and a WorkItem table that are in a many to many relationship using a WorkItemAttribute table. The WorkItemAttribute table contains the foreign keys for each and a value column specifying the value of the associated attribute.
I wrote a simple CRUD web api and tests dealing with the W... |
I'm getting into microservices architecture and there are some issues which are badgering me. The main advantage of microservices is scalability. Let's say that I have service and I'm running 1-n instances of there services.
In case of spring boot application, we have cool easy to implement cache mechanism, but our in... |
For example, I find myself using software X.
Software X has a github repository. I find that I can make a lot of serious refactoring changes that are not small, and reconfigure the entire repository to use a different software methodology. i.e. software X is written using procedural style non-object-oriented coding. ... |
I am designing a web application with Django as the backend. Overview of the system is as follows
Data is collected from user related to different entities. Example : Plant, Project, Machine, Test, etc.
Configuration Blocks (consolidated, fully self contained, dated & versioned JSON files) are created by user by selec... |
I want to design a REST API given the following data model :
Accounts
UserId | Balance
user1 | 500
user2 | 200
And given the following Ui that must use the REST service for it's operation for a transfer of funds.
What would be the best way of designing the api for this data model that must also support the t... |
I have a web application written in Java, Oracle, and AngularJS. I want to save log in database when user changes, creates or updates something.
There are two way of implementing this:
1. Auditing tables via Triggers
Cons: On database level I don't have user information who makes changes, so I have to save userName in... |
We are implementing CI/CD in our company and we have a regulatory project which takes a long time to test. There is no way to break it down since the project contains around 300 rules, each of which needs to be tested every time. Other projects have a much smaller time of testing and they checkin with the mainline much... |
How do I understand Hilbert's map in this answer? The author of the answer has mapped the hash value (integer) of some strings to a 2D image. I understand that Hilbert's curve is a technique for 1D <=> 2D transformation which preserves locality of the points.
My question is, what can I infer from this 2D image about t... |
With WebSockets, when clients should be notified that data changed, I've seen two approaches:
the server pushes the data modifications directly within the push;
or the server pushes no data, and the client, on receipt, triggers an API call to get the updated data.
Which one would you use, and in which case?
In my cas... |
I'm building a web application, which involves (currently) a REST backend and a frontend SPA. The backend is hosting massive geo-enabled data, and the frontend is displaying it on a mapbox map. I'm hitting performance issues, because of the stack I set up. Here's the stack, when it comes to displaying a map.
Mapbox... |
After some consideration I ended up seeing that Service Fabric Actors is probably the best way to start. Now, I'm wondering if I'm approaching this the right way.
The structure
Below, is the structure i came up with.
Summary
I have a Stateless Service (DeviceCalculatorManager) which is responsible for mapping the rece... |
I am running into an interesting scenario that I just haven't been able to get answers on. I would like to see if there are elegant solutions for this. Here are some use cases:
I want to pass the identity/user principal of the user that called an API Action in a Controller to Services and Repository layers. There are ... |
I'm trying to solve a problem that exists for a sport. The sport is fragmented into many federations, and each federation is completely isolated from other federations. The sport is the same for each federation. The problem I'm trying to solve is to aggregate all of the data from each of the federations (about 10 of th... |
I'm thinking about implementation of command/query pattern and I have following solution:
Interface for queries:
public interface IQuery<TResult, TArg>
where TResult: class
where TArg: class
{
TResult Execute(TArg query);
}
Implementation:
public class TreesTransQuery : IQuery<List<Trans>, GetTree>
... |
On an entry level for a codebase you are not familiar with, how do you introduce testing, an at what levels ?
When introduced to codebases with no tests at all and at the same time being tangled together, it's difficult to measure where it's best to put in the energy.
I often pick a smaller corner to start from but in... |
I use a third party API on my webapp that is accessed when the user requests a particular ressource. I'm worried that the successive API calls happening upon user's request might cause the user to wait a very long time and slow down my system (since the thread processing the initial request is also waiting on these API... |
I am having a dilema on a html/js application I have been requestyed to handle drag'n'drop events in order to display a dropped image in a div if is not from images that are already displayed in my app then upload them as well.
My problem is how I will know if is an in-app image or not?
A sample code that describes th... |
The situation: Our team of developers and testers is transitioning from ClearCase to git, in some pioneering fashion. While experience with git is limited there is some familiarity with Linux, cygwin and msys; nobody is afraid of the command line, and people were generally not very happy with ClearCase (although, of co... |
Let's say you are working under Scrum and you have a story which very clearly describes, most likely in BDD, what is required as a new feature in the application.
Let's also say that, as a developer you have enough clarity to begin writing your server side code.
Also, you do not know the language, platform, APIs or per... |
I'm trying to model the security of my project using DDD but I ended up in a dead end.
I have the User, UserA, and UserB classes that were modeled as follows. What changes in practice is that UserA objects have an access policy different from UserB and for this I thought about using the STRATEGY pattern as a good optio... |
The following question is from Introduction to Software Testing by Paul Ammann and Jeff Offutt.
Consider the simple path [3, 2, 4, 5, 6] and test path [1, 2, 3, 2, 4,
6, 1, 2, 4, 5, 6, 1, 7]. Does the test path tour the simple path
directly? With a side trip? If so, write down the side trip.
Can someone explain t... |
When doing test setup, is it better to use low-level APIs to get my system in the right state, or use the same abstractions that my application would use? I'm specifically interested in what promotes long-term maintainability in large codebases.
Example (in Ruby, but my question is language-agnostic):
A User can buy an... |
I just started my first job as a software developer over a month ago. Everything I have learned about OOP, SOLID, DRY, YAGNI, design patterns, SRP, etc. can be thrown out the window.
They use C# .NET Webforms and do almost everything within the Code Behind with very few external Classes, definitely not called objects. ... |
I have list boxes and model relationships in the database. I'm doing the following migrations to maintain lists, rename items, and add items:
def up
Fund.create min: 0, max: 1_000_000
add_column :sectors, :order, :integer, default: 0
Sector.create name: 'Agriculture', order: 1
Sector.create name: 'Con... |
I had a quick question and I was hoping someone could help me figure this out. I'm new to Java and I'm trying to learn about classes and objects and I see you can call parameters in the constructor of the class. Such as:
public class PairOfDice {
public int[] dice = new int[2]; //Create an array of length 2 to ... |
I am requesting information about a Users address and as is good practice when collecting information, I validate the input and respond accordingly where appropriate.
Assuming valid input is received, the format of the input (particularly character casing) could be a bit funky.
For example; given the input 34b bAker ST... |
i have a static IP from my ISP(for eg-> 123.202.21.45).
i have configured my router with that Static IP, and my laptop is connected with that router and its ip is 123.202.21.45. works great!!
but now i connected my phone and iPad to same network and getting same IP (123.202.21.45) on all those devices and internet stil... |
I am working on a legacy C++ code with two libraries.
Library1 is the main and Library2 uses classes from Library1 (so there are some #includes "HeaderFromLibrary1" in Library2).
Deep in the code of Library1, there is some work done and when something happens I need to set a boolean variable. Library2 has to be able to... |
I have a class which checks for differences. I could call this
class ViolationDiffer
public IEnumerable<ViolationChange> Diff(
IEnumerable<Violation> old,
IEnumerable<Violation> new
);
Or
class ViolationDifferentiator
public IEnumerable<ViolationChange> Differentiate(
IEnumerable<V... |
I have a simple "Index" object defined as follows:
{
"position": 4,
"value": 345
}
And I'm trying to figure out the best way to store this object in a mongo database, assuming that:
The "position" of each Index is not necessarily unique and does not depend on other Index objects
Each user can have a huge number o... |
I have customized a free downloaded web template as my simple, static website. It contains HTML, CSS, and JavaScript/jQuery.
I want to make it live, and am confused from where to host it. The hosting providers say that as my site contains JavaScript/jQuery it will have to be hosted on a VPS, which is very costly. I don... |
I plan to have server which consumes all data sent from clients. I want to use messaging system (RabbitMQ) to avoid all troubles with discovering services, recoveries and so on. Client just publish the message whenever the message broker is available (whenever the connection is available). So, my server is sink here an... |
Please refer the following two forms of the same code
First:
<?php if(some_condition){
?>
<li><a target="_blank" href="example.com/channel1/" class="xyz">If content</a></li>
<?php
}else{
?>
<li><a target="_blank" href="example.com/channel2/" class="xyz">Else Content</a></li>
<?php?>
}?>
Second :
<?php
... |
I know they can be more natural to write, but I'm finding it conceptually hard to 'read' fluent API method chains. There's so much going on in a couple of lines.
As an example from the Nest ElasticSearch API:
var result = Client.Search<AutoSuggestItem>(s => s
.Source(sf => sf
.Includes(f => f
.... |
Having built a couple of moderately complex API's - both in Laravel - I appreciate the value of transforming data before sending it in a response.
What I am struggling with is how this data should be handled when it comes back, so for create and especially update methods. Should it be transformed (but in reverse)?
For ... |
I have encountered this problem a number of times. Let's say you have a large object that you want to store in the database. Perhaps it's a dating profile for a user, and it has 100 fields. All of these 100 fields should have a value, once the profile is complete.
However, you want to avoid forcing the user to enter... |
I have a requirement for a reporting tool in which the user will be selecting the "class" that has some associated column and "filter" option in the view.
Each class is associated with a list of columns in the table and each filter condition will add some filter criteria to the "select" queries. We have a script in pla... |
I am talking about single thread general purpose memory allocation/deallocation from a global 'heap' as e.g. every C programmer knows in the form of malloc()/free().
I can't recite the actual title of a paper about a much-better-but-alas-somewhat-restricted-in-usecase allocator, but I think I read the same judgement on... |
I am designing a REST API that allows users to register and authenticate with an email address and a password. Before being able to authenticate, I want to ensure that the user owns the email address they are using, so I send them a verification email with a token. My issue is that the token can expire, so I need a way... |
Our team is growing, and with it, discontent with common coding standards being imposed on developers with alternate (strong, bordering on religious) views on what constitutes a good coding style.
Examples of points of major contention:
Spaces vs tabs
Placement of braces (K&R, GNU, Linux kernel, Stroustrup etc)
The li... |
I am looking for a "test" to determinate which IDE is more productive.
I imagine this is a project in the desired language (my case would be javascript react, or Ruby) and I need to follow instructions like:
Refactor class A and rename it to B
Write a short function that does "this little job".
Search for a method ca... |
Pretty much almost all frameworks I use in programming uses the height and width when identifying a flat dimension (without Z axis), but when in math, a 2 axis object is always measured by length and width. What is the history behind this naming convention?
|
I have 2 classes that have dependencies.
public class AuditManager
{
//set of methods
public static AuditManager Singleton= new AuditManager();
public int AuditEvent(int x){
Event event=new Event(x);
event.SaveToDB();
}
}
Also I have a class:
public class Event
{
in... |
Our product is released every month. I'm looking at popular git flows like the ones in the official git site or Atlassian's. On a high level it is recommended to:
Develop in develop branch
Create a release branch
Test and prepare
Pull request to master
While I understand the need for the release prep step, I'm worrie... |
After some google search, I feel still in the mud.
I am wondering whether what is the best approach for writing wrappers mapping two similar APIs that offer similar semantics but perhaps in different models, syntax or styles.
For example: map Cairo (a graphics library) into Java2D (another graphics library, with a fair... |
I try to build an app using the following layers
Controllers <-> Application Services <-> Domain Services
<-> Infrastructure
Some validation might happen in the Domain Services and I am trying to find o a way of getting such information to the Application Service which will send i... |
I am working on a project, for which I want to create my own file format to store large amounts of data. I am trying to decide how that file format should be built to be as efficient as possible.
The data I want to store is basically a big data structure.
The idea I am currently examining, is storing the data in a way ... |
I'm reading about "Factory method" design pattern from "Head First Design Patterns". So, there is a class
public class PizzaStore {
SimplePizzaFactory factory;
public PizzaStore(SimplePizzaFactory factory) {
this.factory = factory;
}
public Pizza orderPizza(String type) {
Pizza pizza... |
I am writing a Spring boot app with Thymeleaf, which should support two languages (or more). I have set up the locale resolver and messages.properties so now my app can translate static messages on locale change.
The problem is, because there is some data in my MySQL database that have text in it (for example, descript... |
I have a scientific model that is typically run by providing it a complex text-based input file. I would like to provide a service endpoint to allow users to instantiate the underlying model. The simplest thing I could do would be to create a RESTful service that lets a user POST the text-based input file to the serv... |
I need some real time estimation samples from big companies like google, facebook and apple etc.
I need the task description, time estimation for task, team members count and after all, the real time consumed for design, develop, test and deployment of result.
Is there any real data available? All documents about time ... |
My project has a UI layer, a Service Layer and a Repository layer. The latter has Entity objects as part of the ORM (.net Entity Framework).
The service later returns a Dto to the UI layer.
My question is what object should the service layer work with? Should I return the Entities to my service layer methods for perfor... |
I am writing a web app. I want users to be able to go to a URL and start a new "session" of my app. They can Slack their friends/colleagues the URL and then everybody is in a socket-connected scenario where the originator can pose questions to the group, who can answer anonymously.
Right now, I initialize the user typ... |
As today most of the development is towards the lightweight service and RESTful architecture, is WSDL still needed to describe these services? In today's world -- where cloud computing, mobile computing, and Internet of Things are dominating -- is WSDL and UDDI still used by industry or practitioners?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.