instruction stringlengths 34 19.9k |
|---|
How do you approach theme and styling of an Android application? I have all the functionality and I'm now styling and dealing with colors, etc. This is my first big time Android app, and it seems like a huge pain writing some XML, rebuilding and running the app on my phone, looking at results, most likely sighing, and ... |
Is there something special(i.e. a design pattern being related) to a method named create()?
Background
The case is, I often make some instances of objects (of the same class/prototype). These objects do not always already objects reflect a state in which they are complete yet. Potentially some initialization needs yet ... |
I've been reading into Model-View-Controller and was wondering where something like a XyzClient class would fit into this design. Splitting up MVC is easy when all you have are some views to display, some code to handle user interactions and some (maybe persistence driven) database entities.
But where does something li... |
Imagine a software for theater owners. You can accept reservations for the different cinema halls. Each hall has a different number of seats.
Say the owner wants to know how many people visited the cinema on each day in the past years. Easy, just query the Reservations table and group by date.
What if we want to know t... |
We develop Android application. We base on old version of similar application developed in our company. This old application was designed by some noobs which didn't follow UI Android design rules.
Now our product owner says: do stuff the same way as old application.
(Small example: user can add items to a list; in Andr... |
Recently I've come to understand that a serious problem at my workplace is the lack of communication between developers. It's odd, because we're a totally open sort of organization. Everyone can go to everyone and ask whatever they need and communication is hardly regulated at all. And yet it doesn't happen by itself..... |
In my upcoming project, I need to integrate a webapp with few other endpoints. Main duty of the webapp will be some kind of thin-client for inner JIRA system for company. Moreover, I'll need to integrate with SMTP server, some-kind of SMS Api (not known yet) and webservice over SOAP. It should be fast and reliable.
Est... |
If I have to write a simple program (25-35 lines), should I divide it even further, in functions which have a few lines and get executed max. 2 times, or to put it all im one?
e.g. if I need to add and substract 2 angles, should I do everything in one function or write one which converts everything back (and forth) and... |
When designing an OOP-based application, should one prefer to transfer information between objects through complex objects that do a lot of handling work, or should I retrieve the data from the holding object first, and hand over many arguments in the call?
Take, for example, an application that does timeseries econome... |
I am developing a web application by using ASP.NET. I would like to hire some developers to speed up my process but I am afraid what If my members take my code and go away? I am just wondering how big companies maintain their product code without falling into wrong hands. For eg: As I said you earlier I am hiring some ... |
I have a method where all logic is performed inside a foreach loop that iterates over the method's parameter:
public IEnumerable<TransformedNode> TransformNodes(IEnumerable<Node> nodes)
{
foreach(var node in nodes)
{
// yadda yadda yadda
yield return transformedNode;
}
}
In this case, sendi... |
I'm having a problem with the design of my application, that neither optimistic nor pessimistic locking tends to solve. Here is a simplified/altered version of the problem that describes the situation.
Premise of the problem:
A document-processing application
A database where documents are stored
Multiple clients simu... |
What do hardened Scrum folks say about planning Sprints around "Major Holidays" lots of stakeholders have a tendency to take multiple days off and the tendency is that we'll miss sprint goals and fixed dates for sprint review/retrospective and planning meetings get all gummed up. (I try to do planning every other Mond... |
The title should be fairly self-explanatory.
We need to update our coding standards, and as part of this process we've been asked to try and follow an industry standard from a recognised/knowledgeable body rather than just rolling our own. It allows us to demonstrate that we're using widely recognised "best practice" a... |
Consider the following c# code:
public class ExceptionManager
{
public static void TreatException(Exception ex)
{
if (ShowAndContinue(ex))
// display a user-friendly message on what happened and let the app run.
else
throw ex;
}
// (more code)
}
(Please note tha... |
Is there any valid reason why a catch block on a lower layer would throw back an exception caused by a higher, unknown layer using the following syntax:
throw ex;
... rather than:
throw;
... ?
In the first case, not only the catch block doesn't deal with the exception, but it also reset its StackTrace property, makin... |
Question:
Which design pattern do I use to help me refactor legacy SQL code into separate classes?
Goal
Bring in concepts of data separation and database separation and also latest modern techniques I may not yet be aware of (if any), to bring quality to spaghetti-coded test-less legacy PHP code base.
Details:
I am loo... |
I believe I know the answer to this but I'm looking for any holes or anything I may be missing.
This is focused on Spring and Java but could really apply to any programming stack.
Anyway, we have a typical service layer annotated with @Transactional in Spring. For example, we could have:
EmailService
OrderService
Hist... |
I'm trying to find a good resource, advice, etc in a project I've taken on for myself at work.
Background
When I started here we had a application that was part MVC part Webform (separate projects on solution) that was tightly coupled to it's DAL with business code all over the place.
I refactored the entire solution i... |
I would like to validate point in a two-dimensional rectangular Cartesian coordinate. I found following regular expression solution on stackoverflow ^(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)$
. Another solution is using little PHP controls:
$xy = explode(",", "-3,3");
$return = array(0,0);
if(is_array($xy) &&... |
We use SonarQube to analyse our Java code and it has this rule (set to critical):
Public methods should throw at most one checked exception
Using checked exceptions forces method callers to deal with errors, either by propagating them or by handling them. This makes those exceptions fully part of the API of the method... |
I am trying to prevent a function/method (in Java) from performing recursion more than a depth of 3 self calls. I've learnt about the accumulator trick from odersky's scala coursera course.
public void myMethod(File arg, int accumulator) {
//...snipped...
File newArg= ...;
if (accumulator + 1 > 3)
... |
As a preface I will state this is for a homework assignment. I have already discussed this with the professor and will not be using this design. This purpose of this question is whether or not the defined algorithm is greedy. Also if this is in the wrong section I apologize and please let me know where it should be ... |
So I'm currently in my first year in university studying electrical engineering. I'm taking a intro to C course, and I'll say it now, I'm not sure if I'm going to be able to pass the exam. Even with the help of my father I find programming extremely hard. If you give me a code to trace and figure out what's being print... |
I was always wondering about this, because I have been recently reading about many leaks and stolen programs on certain news sites:
If a program (running on a server for example, serving http clients), which is closed source and not released to the public, that uses a LGPL or GPL library gets stolen, can the owner of t... |
I'm starting to develop my first webapp, and I'm using django.
Before anything I'm working on the software logic, how it should work, the links and objects it needs.
The problem is:
I need the app to create a new database for each new client(superuser) of mine. And this db should record some models containing info abou... |
I'm trying to simulate clients going into a bank and being served by tellers over a period of time. I am using a thread to determine if a client came into the bank via an arrival rate and am using multiple threads to represent tellers with an s service rate. I am using a struct to hold the period of time, arrival rat... |
I'm new to the open source community. When I look at projects on Github I don't see any "forum". There's only an "issues" page. Is that only meant for submitting bugs? Or can I say other things? for example:
Can I suggest features? e.g. "I have an idea. It would be great if this project had this and that."
Can I ask q... |
These terms got mentioned in my university course. Quick googling pointed me to some university papers, but I am looking for a simple explanation.
|
I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons).
One thought (and my current implementation) is to use an action array and call a different action
Action[] array = new Action[9];
array[0] = one;
array[1] = two;
... |
Designing an API, we've come up against the question of whether a PUT payload should contain the ID of the resource being updated.
This is what we currently have:
PUT /users/123 Payload: {name: "Adrian"}
Our route code extracts the ID from the URI and continues on with the update.
The first users of our API are questio... |
Various languages support (some flavor of) coroutines.
One way to discriminate coroutines is whether they are stackful or not (terminology based on Ana Lucia de Moura; Roberto Ierusalimschy (2004). "Revisiting Coroutines". doi:10.1145/1462166.1462167. CiteSeerX: 10.1.1.58.4017.):
stackful coroutines allow that a yiel... |
Let's say I want to test a controller that gets some value from a service and then pass some of all of those values to the view.
Do you test that the view gets the result that the controller took from the service, without taking care of seeing the exact variables being passed, or do you test specifically for the variab... |
I know that Java is by default call-by-value but I am not sure where in the Java Language Specification this is addressed. Google searching only seems to find me unofficial sources but never points to where the actual part of the specification that describes this is.
Where in the JLS does it state that Java is call-by-... |
I am currently working on a ecommerce system that is slightly different in structure to a typical ecommerce system in that you have multiple stores, accessing the same database from different URLs.
So for example i might have:
http://www.site1.com
http://www.site2.com
the above are essentially the same store, they po... |
I have a question about the way I am architecting an API.
Structure
My API structure so far is like so (there is about 10 classes total, but many are similar, so I've reduced to these classes, and removed fields that are not relevant to the question):
Profile
id (unique identifier for this Profile)
Allergies
X-Rays
... |
I'm creating virtual keyboard using javascript/html/css. And I can't find a good algorithm for moving from one button to another in different directions (top-bottom, left-right). Lets say I have focus set to any of the buttons - how should I find which button should be focused next. any thoughs and idea... |
I am trying to introduce to my team a more sophisticated branching model than "commit to master and push".
We are a small team of two analysts, three developers and one tester. At the moment, a developer will commit their changes to master, then build the master branch on our test environment. They will then notify the... |
12 Factor states that applications should log to the console, those console logs should should be unbuffered, and the logs should be redirected to someplace useful (file, database, whatever).
But writing unbuffered data to anywhere is extremely slow.
Does this mean that 12 Factor is inappropriate when an application ... |
I have been asked to do a code review of about 50 applications over a period of 6 weeks. (Management has changed and the new CTO asked for an full internal software audit)
I am wondering, what are the key areas to evaluate software on?
(The focus should purely be on the quality of the codebase and not e.g. how it was ... |
A project that I am working on has the following code for interface
example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test
{
public interface IDeviceEssentials
{
string Model { get; set; }
string Manufacturer { get; set; }
string BI... |
Why is that python is treated as only an interpreted language when there is in fact a compiling stage where the code we write gets converted into byte code(.pyc), which is later interpreted by the PVM. Is it wrong to say python is just an interpreted language?
|
I am trying to build a Tumblr Site that makes API calls to Social Network sites and return data and render on the Tumblr Site. And the thing is Tumblr doesn't allow PHP on their HTML Editor. So my decision was to create my own PHP API that calls the Social Networking APIs, then call my API via javascript on the Tumblr ... |
We were using git gerrit for manual code review . but recently we are planning to integrate sonarqube in our Jenkins integration server. Do we still need manual code review? Or we can stop manual code review and sonarqube is enough. I would appreciate if you share your experience with sonarqube.
|
I've written an open source library for iOS, and I've received an email from an overseas developer who wants to pay me for my work so that he doesn't have to attribute in his app.
The code is released under the MIT license, which allows for reuse so long as the license is distributed along with the code. I told him tha... |
It make sense to make class String objects immutable with following declarations, because they share the same storage in common pool.
String str1 = "abc";
String str2 = "abc";
But, am not sure, if it make sense to have class String objects immutable with following explicit constructor declarations, because they do not... |
I would like to know how the data representation is exposed in slide 7 of information hiding:
Modifying an exposed data representation propagates to all code which directly accesses that representation
Perhaps the best example of the impact this can have is the Year 2000 problem
Legacy software for applications as di... |
While reading about Java Programming I couldn't get why it states Java static main necessity reason is because "before you're program starts,there aren't any objects to send messages to" as said in slide 8 of static variables.
The reason why I couldn't get this is why do you need an object to execute a program. I think... |
A program I'm currently designing makes heavy use of the database, almost anything the user does will alter the database, or read from it. Now I have one interface which defines all these operations, and one database class which implements it.
The result is that that class is huge, it contains logic for creating users... |
I've got several applications and websites that will be built around one main application. In a perfect situation users will be able to register once and be able to log into the different applications and websites using that single account. The different parts will be:
Main application (Windows application) that uses ... |
The samples in question are c#, but it applies to any language.
If you have a function which reads content from a stream. Who should be responsible for ensuring that the stream position is correct before reading?
The caller, or the function doing the reading?
e.g.
Caller positions the stream:
public byte[] ReadByt... |
Does class Availability makes programming as Object Oriented Language ?
Most of the people think that if there is Availability Class in a language, then that language becomes Object Oriented. Is it true ?
According to me, its not class that makes the language object oriented, but the OOP Concepts that makes the Languag... |
I work for a very large company that would like to use RabbitMQ.
RabbitMQ is licensed under the Mozilla Public License, v1.1
https://www.rabbitmq.com/mpl.html
The problem scenario, as I understand it, is this:
Just say a contributor to RabbitMQ decided to sue our company for any reason
If we countersue, then we lose a... |
I use Laravel as a PHP framework, although the question is not exactly about laravel, more about structuring controller methods.
I have a route to orders page. Depending on the user role I need to include different views and I have different logic for each role. It looks like this:
public function index()
{
... |
Although here I will refer specifically to C++ and Bjarne Stroustrup's naming conventions, in principle, I've seen that people use somewhat similar rules for other languages here and there.
So, the basic idea is that one should be able to distinguish standard types from user-defined types while reading the code. For in... |
For the below relation between Container and Componentin java.awt class hierarchy, I see that,
in addition to is-a relation, class Container has composite relation with class Component with below line of code,
/**
* The components in this container.
* @see #add
* @see #getComponents
*/
private... |
I want to write a code which computes the sum of divisors of a number N(1 ≤ N ≤ 1 000 000 000), excluding the number itself.
However, I need an efficient way to do it. It suppose to print the answer under 1 second. I know it depends on hardware etc. But I have an i7 machine though it takes more than a second (for the ... |
Could anyone explain why short(100000) is -31072 as said in p.48 of java-notes.The article says that "the value -31072 is obtained by taking the the 4 byte int 100000 and throwing away two of these bytes to obtain a short".
The code in the article related to the question is:
int A;
short B;
A = 17;
B = (short)A;
|
A little explanation might be needed. I mean mutual credit the way that it's defined here:
a type of alternative currency in which the currency used in a transaction can be created at the time of the transaction
Imagine you have a network of accounts. Each starts out at zero and any account can extend a limited line ... |
What I want to do:
Parse source code, search for a beginning and closing tag of my own definition (one that does not conflict with any defined patterns in the programming language), and then replace then everything from the beginning of the opening tag to the end of the closing tag with some function of the data within... |
I'm an iOS developer and I'm guilty of having Massive View Controllers in my projects so I've been searching for a better way to structure my projects and came across the MVVM (Model-View-ViewModel) architecture. I've been reading a lot of MVVM with iOS and I have a couple of questions. I'll explain my issues with an e... |
Let's consider this C code:
#include <stdio.h>
main()
{
int x=5;
printf("x is ");
printf("%d",5);
}
In this, when we wrote int x=5; we told the computer that x is an integer. The computer must remember that x is an integer. But when we output the value of x in printf() we have to again tell the computer that x ... |
Should an event listener be called if it is attached after the event has already fired? What if the event will only be fired once?
The first example that comes to mind is the ready event in jQuery. The following snippet, when evaluated after the page has loaded, will still call the callback:
$(document).ready(function ... |
I develop code review tool which analyzes the code and gives it passed grade and output details of code review.
I want to prohibit to use this software for recruiting/hiring purposes. I don't want to be responsible for someone doesn't going to be hired because of my software. I don't want to prohibit for development u... |
I'm coding a neural network in C for an OCR project. Before testing with character recognition, I'm making it learn the XoR operation. Although, the results I'n getting always converges to 0.5 instead of 1 or 0 for all input combinations.
I'm using a learning rate of 0.35 and the activation function is the standard sig... |
I have an unexpected situation in a project in which all types extending one class are packed into a Java collection; but only a specific extension of that class contains an additional method. Let's call it "also()"; and let me be clear that no other extension has it. Right before performing one task on every item in t... |
I work for a company that use a custom DSL and my job is to port the VM to C++.
I'm trying to do this in compliance with the C++11 standard so i use auto when appropriate, the new for syntax, etc. But I'm having problem trying to "port" a part of the code that uses raw pointers to the new smart pointers.
On this DSL ev... |
From what I've read I believe user requirements are just the system requirements given in lay mans terms, is this correct? I'm specifically referring to the book "Software Engineering" by Ian Sommerville which I am obligated to follow. Given the example below from said book, why is there not a user requirement to match... |
I am having trouble learning about the impact of web components and shadow DOM on the browser, specifically related to repaint.
I remember reading at one point that the shadow DOM nodes have encapsulated repaints, which greatly enhances performance, but I cannot find any articles about this, so it seems like speculatio... |
Our process continuously feeds (normally <= 8) ingredients from a choice of hundreds, using 3 feeders only. So if ingredient count X is > 3, 3 through X are stirred together in a batch process and the resulting "premix" gets put in its own feeder. 6 is a hard limit for the number of ingredients a premix can have. It is... |
I have an upcoming internship interview with Microsoft and, although I rarely use break in my own code, it does simplify things a lot of times and bring me to a solution faster when coding on the whiteboard.
To anyone familiar with the interview process, would it reflect badly on my coding style? I'm not asking about w... |
the question is self explanatory, I just want to know when to use the inclusion and when to use inheritance, and which one serves for re-usability.
in other words, which one meets the Object Oriented programming principles the most?
|
I am planning to write an app that needs phone number and contact list. Is there any way that I can test my app without buying a telecom provider connection for my android phone. Without a sim the phone doesn't have a phone number and I am wondering if mock phone number is only way to get pass this.
|
I had been through this query before asking this question.
In class Window we have constructor with default direct access level package private but not private as shown below:
Window() throws HeadlessException {
GraphicsEnvironment.checkHeadless();
init((GraphicsConfiguration)null);
}
With class d... |
As per the class hierarchy in java.awt.*, class Button & class Label is-a class Component, and Component is not a Container, which make sense to me.
As per the redesign of class hierarchy in javax.swing.*, class JButton is-a class JComponent in-turn class JComponent is-a class Container,
So, What does it mean to say th... |
I have an application that needs to log communications with users over several different mediums: Email, SMS, Voice, Website Announcements, etc.. in a traditional database.
I have considered 3 approaches to modeling these different types of data:
Single Table Inheritance:
Store them all together in a single table (i.e... |
I would like to develop a library that:
receive n players in input
response with the tournaments brackets in output.
I would ask you what kind of algorithm I have to use to choose the correct tree that have to be generated for each input.
I am interested on single elimination tournaments, and players of the same club... |
There are very complex open source projects out there, and to some of them I think I could make some contributions, and I wish I could, but the barrier to entry is too high for a single reason: for changing one line of code at a big project you have to understand all of it.
You don't need to read all the code (even if ... |
MDN article on Node interface states that
interfaces [that inherit from Node interface] may return null in particular cases where the methods and properties are not relevant. They may throw an exception - for example when adding children to a node type for which no children can exist.
To me it seems like a strengthe... |
Is having empty children classes, just to specify, a bad practice?
Lets suppose I've a generic Product class. There are electrical, electronic and mechanical products. I need to represent all them and must be able to differ each one in some operations.
I've two options:
add a member named "type" in Product class to sp... |
To put this in context, I have the following scenario. I am writing a Common Lisp program that works with strings and lists of characters.
In a certain function foo, the value of a variable suff is a list of characters. Further on in the code, I forgot that suff was a list and treated it as a string, calling
(subseq su... |
In OO languages, at least C#, everything has to be in a class. Sometimes, everything is in a namespace as well.
Just about literally all the code in one class is going to be automatically indented by a tab stop or two, which is seriously pretty pointless if it doesn't help with code readability.
The issue with just r... |
I have a designer who has great knowledge of HTML, CSS and JavaScript (Not jQuery or AJAX though).
He gives me his designs in those files and I have to incorporate it into my apps.
The site is not static so I have trouble incorporating it.
When the site was static I used to save the HTMLs in my app/views directory and ... |
I'm familiar with MVC web frameworks and lately very familiar with Symfony2.
I want to start learning Spring, and the first practical problem I would like to try to solve is handling the reuse of javascript libraries.
It's been a while, but in Symfony2 my solution was to create a bundle with a Twig (template engine) e... |
I'm trying to get started on a side project using a mobile device (tablet or smartphone) as an input device to a PC. In its most simplest form, I envision using the mobile device touchscreen to control cursor movement and clicks on the PC. So far I'm targeting Windows machines and either Android or iOS devices (using... |
Consider an^2 + bn + c. I understand that for large n, bn and c become insignificant.
I also understand that for large n, the differences between 2n^2 and n^2 are pretty insignificant compared to the differences between, say n^2 and n*log(n).
However, there is still an order of 2 difference between 2n^2 and n^2. Does t... |
As far as I am aware, python is generally referred to as 'call-by-sharing', but does it implement this with call-by-value (like Java) or call-by-reference? or something else? I would appreciate if this could be answered with official python documentation (in which I can't seem to find the answer) as opposed to anything... |
Take an arbitrary "perfect" multi-threaded program, on an arbitrary multi-threaded platform, using an arbitrary programming language.
Assuming that this "perfect" multi-threaded program:
is flawless in terms of race conditions
handles shared memory perfectly
may/may not use a locking mechanism (thread suspension or mu... |
I have a object which has a few base variables (integers as example) and one intermediate variable for further processing. The intermediate variable can be calculated from the base vars. Now the question: Should I always repeat the calculation of the intermediate var from the base vars or should I save the value and on... |
Lets say I have a class representing a chemical compound
class Compound(networkx.Graph):
def __init__(self):
super(Compound, self).__init__()
And lets say that I want to add some extra functionality onto a chemical compound. It should probably inherit from Compound. But is it okay to just use it as a w... |
I currently have a basic j2ee website. Currently, a jsp frontend gets data from the backend (the java program, lets call it object "Score"). The backend gets this data from a web site.
<% Main m = new Main(5); %>
<table style="width: 100%">
<tr>
<th align="left">NBA</th>
<th style="text-align: right"><%=m.ge... |
Suppose that you have a range of numbers from 0 to N that you want to randomly separate in groups of max M sequential numbers. This is easily done with a bitmap and a random number generator, but it is not space efficient for very large instances of N.
So, what I want is a generator that, given a number N and M, will s... |
I'm using a PRNG (PHP's default rand() implementation) to generate unique 16 digit numbers. Does it make sense to generate digits one by one, or the number at once?
I'm using PHP.
|
I want to implement Lucene for full text search. I have a table with 6 million records in an sql database. Each minute around thousand new rows will be added from the application.
Index creation in Lucene takes a lot of time. Each time I delete or create a new index from the database because the user needs to see the u... |
I would like to know why do we need to use constructors in examples like this:http://math.hws.edu/eck/cs124/javanotes5/c5/s2.html. I think even if there are no constructors the programs mentioned in the link might run.The code is:
public class PairOfDice
{
public int die1; // Number showing on the first d... |
I've been researching git deployment flows and have seen many post-receive hooks that will check out master. Few of them however detail how you might set up a beta server that could be running any arbitrary commit ref.
My first thought was that you could set up a branch per environment and then push it. But I'm wonde... |
PrePros a compiler for the LESS/CSS languages is licensed under MIT
But from version 5.0 it being presented as 'Shareware' which requires payment and activation, although it does not impose any limits but prompts you to pay and Activate
I really don't understand what the deal is here. Am I required to pay for using it ... |
tl;dr: Why would I ever choose to write/compile unmanaged1 code?
Lets assume that I am starting a new project. I have decided to write in a C-like language - probably one of C, C++, C# or Java. C# and Java are managed (well, Java runs in the JVM, but lets assume that it is same thing). Managed GCC plugins exist (althou... |
For the below sample GUI program using javax.swing,
public class UnResponsiveUI extends JFrame{
private boolean stop = false;
private JTextField tfCount;
private int count = 1;
/* Constructor to setup the GUI components */
public UnResponsiveUI(){
Container cp = this.getConten... |
I am currently in a sprint (two weeks) where the designer is tasked with defining the requirements and UX of a particular user story.
In the same sprint, I am to implement this design. During sprint planning, I had to take a wild guess as to how long this undefined user story would take.
Today I finally received the de... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.