instruction
stringlengths
71
71.9k
With the Zend coding convention in the back of my mind, I have set this up. It lets you communicate with the API of the vendor TargetSMS. They allow you to bill customers trough SMS. For now I've only spent time on the NonSubscription option. I would just like to know if it's ok, or what could be better. I am mostly i...
I have written a program, in which I have to find the number of occurrences (overlapping + non-overlapping) of a string in another string. // variable to keep track of word int i=0; for(vector<string>::iterator it = p.begin(); it!=p.end(); it++){ frequency[i]=0; int start=0; while(true){ start = s.f...
Instead of using multiple setter functions within a class like public function setAction() public function setMethod() etc I've been using a method from a base class that all other classes have access to. public function set_properties($properties) { foreach ($properties as $key => $value) { $this->$key = $v...
This is the algorithm I am using to flip an image in-place. Though it works perfectly, I would like if any one can spot any potential problems or offer any points on improvement and optimizations. /** * pixels_buffer - Pixels buffer to be operated * width - Image width * height - Image height * bytes_per_pixel - Nu...
I would like a review and recommendations for improvement of the code below. I want to allow an exception to be handled by the caller, so I am rethrowing it. But I have resources to close. So I have the resource closing code duplicated in both the try and the catch blocks. Is there a better way to do this? const st...
The interface and some of the implementation is take from Boost. However, it is intended to be transferable between projects by only copying one file. I have removed most of the policy classes in favor of more condensed code that requires less files to move around. Please tell me where my strengths are as well as where...
I am learning to use Java Swing and have made a simple animation that makes a small shape bounce around the predetermined borders of a panel. The program works well, but I am looking for feedback in terms of quality and any improvements or alternative methods that could be used in such an application. import javax.swin...
This is a quick question. I am reading a mass amount of JSON from a variety of text files. The JSONs are tweets, in this format: {"filter_level":"medium","retweeted_status":{"contributors":null,"text":"Daily Mail: Vincent Kompany says Manchester United are favourites http://t.co/NB2p1cqlRs #mufc","geo":null,"retweeted"...
I have an application with HTML, external JavaScript and a bit of jQuery on the page which is initializing specific stuff to that page. I try to keep most of the JavaScript in other files. However I'm unsure if stuff in the DOM Ready function should be split into a separate file as well which is specific to that page. ...
In a former question on SO I described a problem with a construct called 'EnumBase'. As I sad there, I am not involved when basic implementation happened. So I'm not sure why the thinks are a they are. I only know that the code was written in times of .Net 2 and 3.5. The derived classes are useed as DataSources in ASP....
I'd like a general opinion on my piece of code (which does exactly what I want it to do). I feel like I'm using bad practices, like a DB query within a foreach loop, or grabbing the lowest value in a non-elegant way (sorting, then using the object with an index of 0). I'm also not sure on my usage of the DB queries ins...
In a Rails application, I want to have a complex form with some dynamic behaviour. For example, I want to show a part of the form want I check a box or I want to have different values in a select box when I choose a radio button. I do this with JQuery. My problem concern the archirecture. I created a form object and I ...
I have a simple encryption module that is used to "encrypt" a text file because it contains some passwords. I only need to encrypt it because I need those passwords in my program (they are used to send an automated bug-report email), but I don't want the end-user to be able to see them. My "encryption" function is VER...
Coming from a Java kind of OOP, I miss a lot of things in JavaScript. I am working on a Node.Js project, and I would like to use an OO approach. Looking around and asking in StackOverflow I came up with this example scenario (jsFiddle). function inheritPrototype(childObject, parentObject) { var copyOfParent = Obj...
I wrote this small project to practice threading in Java. At first, I planned to do it like this. But later, someone pointed me to Executor. Then, I found this tutorial and followed it through. Here is my code; /* * HttpStatusCodes * * First version * * 2013-08-12 * * This code is copyrighted under Creative Co...
I'm creating an unordered list element in Backbone via Underscore templating: <ul id="FrontRack" style=" background-image: url({%= data.get('racks').at(0).get('imageUrls')[0] %}); height:{%= data.get('racks').at(0).get('pixelHeight') %}px; width:{%= data.get('racks').at(0).get('pixelWidth') %}px...
This function's job is to replace several text smilies, e.g. :D, :), :love with the appropriate smiley image. In my opinion my code has several issues, yet the main problem is that a lot of quite similar regexes are created dynamically: one for each different smilie replaced. As you might expect, replacing smilies in a...
So we have a RESTful webservice that implements CRUD operations for a model, like this one: class MyModel { private long id; private String name; // other fields private boolean completed; private boolean active; // getter and setters } In this webservice there is also a path like /service/{id}...
I have such a method that performs a long query search against some data. Task<List<SearchResult>> Search(string query){ ... } I have tried various way to create an IObservable form of it but failed. At the end after some google help I wrote such a method. private IObservable<SearchResult[]> Search(string query) { ...
How can I refactor this code to avoid switch-cases? Is there a way of changing commands without adding new case and make it dynamically...I want the solution not to depend on the amount of cases. For example, if I have 1000 commands..I should obviously write them all as cases? I hope my problem is clear. static void Ma...
I was working through getting myself past the creation of a generic method, that converts a List<T> or List<List<T>>, to T[] or T[][] respectively. Well, let's just consider a maximum dimension of 2 for now. List<T> to T[] is quite straight-forward: public static <T> T[] listToArray(List<T> list, Class<T> clazz) { ...
I am doing some console test program, and I have some normal math operations. Example of part of my code: if (flagMultiplyDivide.Equals(true)) { if (currentOperator.Equals('*')) { currentNumberDouble = multiplyNumbers(currentNumberString, temporaryNumberString); if (operatorOnHold.Equals('+')) ...
I am really just looking to make sure I am not making any weird mistakes that could hurt me in the long run or if something seems odd in the way I imagine it to work. This code does work for the way I use it and may lack other more advanced things that I may use in the future but have not implemented yet. I left in my ...
Over the weekend I was perusing the web, and came across the programming problem, finding the longest non-decreasing subsequence in a grid, and I wanted to tackle it. I'm a web developer by profession, and sometimes, honestly, I feel like I fit the bill described by Jeff. I don't feel that I chose web development becau...
I need to refactor following class: public class Message { public Guid ID { get; set; } public string MessageIn { get; set; } public string MessageOut { get; set; } public int StatusCode { get; set; } //EDIT could be changed during message lifecycle public bool IsDeletable { get ...
I'm new to ruby on rails, on this project I'm using Ruby 2.0 and Ruby on Rails 3.0. I would like to know if this piece of code can be refactored, as it is unless params["ot_code"].nil? ots = params["ot_code"].gsub(/\r\n?/, "").gsub(";","','").upcase ots[ots.length,1] = "'" ots = ots.rjust(ots.length+1,"'"...
Just a small code review. Is there a better way to get all folder names? <?php $folders = glob(dirname(__FILE__) . '/myFolder', GLOB_ONLYDIR); foreach ( $folders as $f ) { $lastDsPos = strrpos($v, DIRECTORY_SEPARATOR); $myFolders[] = substr($v, $lastDsPos+1); }
I have the following case statements that has to be modified to fit these cases: Dec, Double, Int, Long, Short, Date, and String. Please let me know if there is an easier way to handle this rather than repeating the following (slightly modified for each case): Case GetType(Integer) If String.IsNullOrEmpty(c.Text) T...
We're using a class called Places (inspired by Allen Holub's great article on DrDobbs) that resolved our program paths based on the existence of a configuration file, environment variable or neither. In the neither case, we want all paths to default to resources within our package, the .jar. Additionally, we want to fo...
I am fairly new to writing unit tests, and I was wondering if this approach I have taken is on the right track? Given the following interfaces/classes: public interface ILoggingService { void Log(string message); } public interface IShoppingCart { IList<IShoppingCartItem> Items { get; } } public interface ISh...
I would love it if someone could give me some suggestions for these 2 graph search functions. I am new to scala and would love to get some insight into making these more idiomatic. type Vertex=Int type Graph=Map[Vertex,List[Vertex]] val g: Graph=Map(1 -> List(2,4), 2-> List(1,3), 3-> List(2,4), 4-> List(1,3)) //...
How can I optimize my jQuery? I remove the extra code to attach click event to the header tags. $("#dnn_htmlPan1.htmlPan").find(":header").click(function () { $("#dnn_htmlPan1").find("p").slideToggle("slow"); }); $("#dnn_htmlPan2.htmlPan").find(":header").click(function () { $("#dnn_htmlPan2").find("p").slideT...
I am reading a book on DSA, and the author explains how to generate the permutation of strings using recursion. I want to know if there are better ways of doing the same, unless this is the best solution. Also, could someone help me understand the time-complexity of this algorithm? Recursion is something I use very ...
I'm a budding JavaScript programmer, working on an exercise where I'm trying to create two classes (Books and Shelf) and need to have a shelf know what books are on it. I'm pretty new to OOP so I know I'm missing a crucial step (or three). I probably already ran off the rails, but any point in the right direction would...
Here is my simple ticketing system: <?php session_start(); session_id(); ob_start(); require("../configuration/config.php"); $GetTickets = $con->query("SELECT * FROM tickets WHERE open='true'"); if(!$_SESSION['Admin']) { header('Location: login.php'); exit(); ...
This is my first MYSQL schema for caching location data (co-ordinates to place names) and referencing it with a country. I was wondering what everyones feedback was on it, did I do a good job? CREATE TABLE location ( id INT AUTO_INCREMENT PRIMARY KEY, locality VARCHAR(20), administrative_area_level_1 VARCHAR(20), admi...
the Encoding scheme is given below: Don't replace the characters in the even places. Replace the characters in the odd places by their place numbers . and if they exceed 'z', then again they will start from 'a'. example: for a message "hello" would be "ieolt" and for message "maya" would be "naba" how many lines of co...
The question is: Write the following pseudo in assembler code: if portC bit 3 == 0 (switch content of var1 and var2) else (add var1 with var2 and place the result in var1) My answer is: btfsc portC,3 goto add movf var1,w movwf temp movf var2,w movwf var1 movf temp,w movwf var2 return add movf var2,w addwf var1,f Sin...
I am trying to write a simple version of the unix tail utility in haskell to improve my understanding of monads. Here is what I have now. I am pretty sure that this is not quite "Haskell enough" yet. Can you please help me improve my code? import System.Environment import System.Exit import Control.Monad main = getArg...
Help me review this code: #include <iostream> #include <cassert> using namespace std; template <typename T> class auto_ptr { public: explicit auto_ptr(T* p = NULL):m_p(p){} auto_ptr(auto_ptr& other); auto_ptr& operator=(auto_ptr& other); T* get() const { return m_p; } void reset(T* p = NULL); T...
As a part of learning Haskell, I've implemented an AVL tree. As of now, I've only implemented insertion. I've compared its performance to a Java implementation I've picked at random (www.github.com/justinethier/AVL-Tree/blob/master/AvlTree.java). It performs almost as well when given an ascending or descending list ([...
If this question should be on stackoverflow instead, please point it out. I'll put it up there. struct { FILE * fd; hdr_t file_header; body_t file_body; } fileinfo; The above is an approximate recreation of a structure that I have in my code. There is a separate function we use for thread cleanup. ...
I occasional write simple yet long Python scripts using Sqlite3 (I'm not proficient with functional or object oriented programming... yet) Usually my Sqlite3 is blazing fast. I'm used to looping through lists of SELECT statements with each SELECT taking a split second, and writing tables to text files in HTML markup. ...
I'm finding it a bit tedious to write unit tests for my collision class because there are so many variations of collisions that need testing. I see repetition in the set-up and assertion stages of each test, but I don't see how I can reduce the repetition whilst keeping the code clear and concise. package tests.kris {...
I had to calculate the difference between Chicago Board of Trade grain futures prices using VB.net and came up with the following (admittedly clunky) solution. It's a little tricky because CBOT prices, as posted, mix octal and decimal numbers. Anyway, here is my code for you to enjoy and tear apart: Public Functio...
I know this is not very good. I am currently in my first programming class (Java). It seems like it works, but I am sure there are things I have not thought of. The goal is to have a user enter the number of credit units each class they need to take is worth, one by one the number of credit units to complete in a ter...
I like the fact that I can create a class and have the connection details in one file if I need to update them and then pass them to the method I create in the class that defines my specific use of mysqli. I was thinking also that I may give an option to pass the connection details if I need to use a different db in on...
How can I optimize the following class? prepareSharing packs bits on left and prepareMask counts the required bits for encoding integers between zero and max. public class KeyFactory { public static short[] prepareSharing( short[] sharing, int mask ) { // Ensure mask is unsigned short // mask &= ...
I'm using Twitter Bootstrap. I haven't coded anything significant web design related in a while, because I've been doing desktop stuff and games. I'm trying to get back into the flow of things. Can anyone tell me if what I have is sufficient without going into ridiculous detail (the script, not the answer)? Partial HTM...
This was my first attempt at writing object-oriented JavaScript. It's a Minesweeper clone in jQuery. I thought I had done an OK job, but I've just received some feedback stating that it wasn't written in an object-oriented manner. I don't expect anyone to read this line for line. I'm just looking for general feedback....
I wrote this as an academic exercise over on CA. It is supposed to tell a true story about two drag racers, one in his 80's who beat a young world champion in cars that traverse a 1/4 mile in 3 seconds at 300 mph. It is structured to let the old man win every time because it is based on a true story. I did it mainly...
I've just started learning HTML and CSS. Currently I'm creating a test site to practice with. I'm just after an early idea if the principles I'm using are correct. The below is an snippet from the main body of my HTML code. It's just about positioning text and images on a grid at the moment. I seem to be using a lot of...
I have some Java like this: if (!fooclass.getInfoText().equals("")) { this.setInfoText(fooclass.getInfoText()); } Is there a neater way of setting one value based on the test results of another value? It seems nasty to me that the method is run twice, but putting the result in a variable when it may be empty and n...
Is anything what could I improve on my code? import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class Helper { public static Map<User, BigDecimal> createPlayersScoreMap(List<User> users, List<Score> sco...
I am new to C and have written this code just to teach myself how to work with linked lists and was hoping someone could review it and give me any comments or tips for efficiency, etc. The code just creates a list, adds and removes nodes from the list, and can reverse the list. /* Creates a linked list, adds and remove...
I have a process that reads multiple sheets from an Excel file, then inserts the data into a database table. However, I am experiencing some memory issues when one of the sheets contains more than 65536 rows and am looking for ideas on how to improve the code. In summary, I am using cfspreadsheet to "read" an uploaded ...
I have a console application that basically retrieves XML content, writes to the XML file and sends the file to an SFTP site: public Main(string[] args) { try { //code to parse arguments to load into DTO to extract stored proc and report name List<ReportInfo> reports = Parse(args); foreach(var rpt in reports...
I have been working on a Magento module for sometime now (not because it is a large module, it's my first and I really struggled with it). I now have it working, which I was really pleased with at first, but now I would like to improve it by increasing the reusability of the code. While making my module I have looked a...
I've created a form that gathers and submits information to SQL database via LINQ, and sends an email if all goes while saving the database and doing a redirect. Recently, it started submitting data and calling errors (thread aborts) within the submit function, which seemed unusual. I solved it by using Boolean flags, ...
What can be done better in this code? I am sure it's not missing much. You can copy and paste the whole thing in LinqPad; it's all there. public interface IRep<T> { List<T> GetAll(); } public interface IEntity { int Id{get;set;} } public class Customer: IEntity { public int Id { get; set; } public st...
This is some C code I have to simply test the internet connection. Any comments/tips on efficiency and refactoring this program down would be greatly appreciated. int testConnection(void) { int status; struct addrinfo host_info; struct addrinfo *host_info_list; memset(&host_info, 0, sizeof host_info); ...
I've been working a lot recently with SerialPort in C# and I've come up with the following class as part of a class library I'm working on for another program. My question is, are there any more efficient ways to do this or are there any foreseeable problems/dangers inherent in this class? using System; using System; u...
In order to separate my views (markup) and code, I elected to write my views like this: <!DOCTYPE HTML> <html> <head> <title>%PAGE_TITLE%</title> <meta charset="UTF-8"> <link href='PotatoDocs/views/stylesheets/docs2013.css' type='text/css' rel='stylesheet'> <link rel="shortcu...
//AMOUNT CALCULATOR var totalAmount = 0; var serviceAmount = 0; jQuery('.select-service').click(function(){ var serviceAmount = parseInt(jQuery(this).parent().html().replace(/\D/g,'')); if(jQuery(this).is('.selected')){ jQuery(this).removeClass('selected'); totalAmount -...
I'm working on a C library which attempts to bring some of the Python string functions over to C. This is where my full source is located, but the majority of what I have so far is here. Are there any places where code efficiency can be improved? #ifndef OCTO_H #define OCTO_H #include <stdlib.h> #include <string.h> i...
I'm currently taking an algorithm course in college. To find the maximum and minimum elements in an array, I'm using a divide and conquer algorithm. Please offer suggestions for this code snippet. I get a headache reading only comments, so please give explanation with sample code. #include<stdio.h> #define ARRAY_SIZE...
Trying to learn FRP and Elm. Is the program below "ok" from the perspective of FRP and Elm? What could be improved? The program can be executed here: http://elm-lang.org/try import Random import Mouse data Fruit = Apple | Orange | Banana | Melon | Guava rand = Random.range 0 4 (Mouse.clicks) fruit n = if | n == 0 -> Ap...
I'm trying to achieve a set of unique array with my following function. The Function: /** * uniqueAssocArray Removes arrys which have same keys * @param Array $array Array to get unique items from * @param String $uniqueKey the unique key * @return Array new array with unique items * @author Junaid Q...
I'm a noob in programming. I was asked to code a program that can calculate prime numbers. So i coded as provided below. But it prints all the Odd Numbers instead of Prime Numbers. I think the Value start is not being divided by all the integers in the range (2,Startnumber). It just prints all the odd numbers. startnum...
I wrote the below code and tested some example files on it. I didn't find any errors, but I still want to be thorough about this. Also, any suggestions in improving the code? import string """ this implements an encryption standard over the message text it replaces the odd place alphabets by their ordinal number plus ...
I wrote my very first directive and I'd like to get some suggestions for improvement. My code - plnkr. webApp.controller('AppCtrl', function ($scope) { $scope.expandAdd = function() { $scope.hiddenAdd = true; }; $scope.addWeb = function() { $scope.hiddenAdd = false; }; }); webApp.directive('enter',functi...
I have the following object oriented class revolving about the PHP super global $_SESSION I shown the script to a fellow developer and he mentioned that all my returns are not necessary needed, whereas I believe that they are? My code is as followed: /* * * * This class will allow control of the super global $_SES...
I am a student, and I am doing websites as freelancer. Lately I have started learning design patterns, refactoring, and test-driven development so that I can improve the maintainability, performance, and readability of my code. I did some refactoring with method extracting in this case, but I got feedback that my code ...
This function is simple, it gets a number of bytes and returns its representation in either Bytes, KB, MB, GB and TB. As simple as it is, I am sure there are other (and perhaps better ways) to write it. function kmgtbytes (num) { if (num > 0 ){ if (num < 1024) { return [num, "Bytes"] } i...
I am trying to simplify the amount of code required here using arrays, I feel like my foreach loop is still excessively long. Any advice would be appreciated. $date_list = Array( Array( 'age', "$birthday", 'now' ), Array( 'membership', "$datejoined", 'now' ), Array( 'promoted', "$lastpromo", 'now' ), ); foreach ( $dat...
I have created this class for my WP theme. It allows you to create templates for a meta box which relates directly to a custom frontend template to have better control of the content displayed on the page. So for example: The meta box content file, which defines a "template": theme_folder/post-templates/templates/admin...
I have this code: for (int i = 0; i < lst.Count(); i++) { lst[i].ColumnOrder = (short)i; } But I was trying to find a way to do it via LINQ or something else with better performance. I'm pretty sure that there are better ways to change the sequence of a column. I use this code in a drag & drop context.
I wrote some type checking decorators for Python. One checks the type that a function returns, the other checks the type that a function accepts. import functools def returns(t): """ Calls a function, and if it returns something of the wrong type, throws a TypeError """ def outer(func): @functools.wrap...
I received help with adding the length of a stream in the first 4 bytes, meaning it's there as an int. I am adding it at the start and sending it, while the receiving part checks for its position. However, the position checking is a bit slow, so I wonder if it's possible to improve it. Maybe using unsafe pointers or s...
Here are my code samples: https://github.com/arthaeus/war This particular sample is the card game 'War'. The interviewer off-handedly asked me: "what if I wanted to play War with an Uno deck of cards?" I threw an Uno deck implementation in there as well, so don't be confused. I have been told that my main() functio...
The navigation in my footer menu looks like this It works, but I get a feeling that using spans the way I did was a bit of a hack. So I would also like to know how to maximize compatibility as used media queries. I created it using the following HTML <div class="footer"> <ul> <li><a href="http://www.bruxz...
I have the following code (I need the LambdaExpression as not all Func<>'s are T, int): var orderDelegates = new Dictionary<string, LambdaExpression>(); Expression<Func<Image, int>> id = i => i.Id; orderDelegates.Add(ContentItem.ORDER_BY_ID, id); Is it possible to make this shorter? Best something like: var orderDele...
I wrote this code to overcome the deadlock condition described in this Oracle tutorial. Summary of Problem: Alphonse and Gary are friends, and great believers in courtesy. A strict rule of courtesy is that when you bow to a friend, you must remain bowed until your friend has a chance to return the bow. Unfortunately, ...
I wrote a custom URL encoding function and I'd like to run it past a few other experienced C developers. I have tested it on a few strings, and it has worked on all of them. This is to be run on iOS devices, so memory and processor use are potentially a small concern. Do you see any potential problems - UB, wrong ret...
A little birdie suggested I bring this question here, so here it goes. Well I have a working script (see below) but it seems quite clunky and redundant; in my defense I wrote this code many moons ago, but that's not the point. I was curious if anyone has an idea on a more efficient way of writing this code, with less l...
I found Project Euler some time ago and I thought I'd enjoy trying those problems. I'm using C++11 (Visual Studio 2012). I thought I'd program a Manager to test each problem and the time it takes my solution to run. I programmed this: ProblemsManager.cpp #include "ProblemsManager.h" #include <algorithm> #include <ios...
I am trying to implement a class that implements a given schedule. I am trying to design this Scheduler class so it can be paused and everything. I have just written some example code so I can better convey my requirements. I would be grateful if more experienced minds could take a look and tell me if what I have right...
This code displays a lot of images based on color in columns. I'm thinking it can probably be optimized a lot better. But I'm wondering if anyone has a more fundamental solution on how this could be improved in regards to speed and legibility. The database has the equivalent of this XML file. Any suggestions? CSS #row...
I forked this repo to be more concise. The code is here. I'll paste it below since that seems to be the style. I removed the class definitions at the bottom that I didn't change -- the edit I'm concerned with is the use of the "class_factory" function at the bottom. Is this good? Pythonic? from selenium.webdriver im...
This is used to create a directed graph of type T. The directed graph has edges and vertices with values but is directional such that nodes can loop unto themselves or only go a single direction even though 2 vertices are connected. Things I am looking to get out of this review are: My use of a hashMap instead of ...
I have a data structure called ClientSession which I convert to a String separated by | for each element and back to the data structure. 18 data ClientSession = ClientSession 19 { sec :: Int ...
Here is the SlimDX version: var form = new SlimDX.Windows.RenderForm("Test"); form.Width = 1280; form.Height = 1024; SlimDX.Direct3D9.PresentParameters presentParams = new SlimDX.Direct3D9.PresentParameters { BackBufferW...
I wrote a PowerShell script for a superuser question: list of all files and directories under a path recursively, without recursing into junction points or links I have a strong feeling that my code is way too complicated for such a simple task. function Recurse($path) { $fc = new-object -com scripting.filesystem...
Background info on factoring and prime factorization. I've remade this program from my first attempt, and I'm sure it can still be improved. My questions: These calculations should only be done with positive integers. Would something like templates help keep this type-safe? What about throwing an exception? Is this...
I'm looking to get some feedback on a small printf-like function I wrote that provides simplified behavior similar to boost::format: #ifndef EXT_FORMAT_HPP__ #define EXT_FORMAT_HPP__ // ext::format // Implements a variadic printf-like function providing behavior similar to // boost::format #include <regex> #include <ss...
I am making some basic temperature conversion methods, and I want the end result to look something like this: double celsius = TemperatureConvert.convert(10, Temperature.FAHRENHEIT, Temperature.CELSIUS); // Where 'Temperature' is an enum with three values: FAHRENHEIT, CELSIUS, and KELVIN // This mehtod is read logical...
IS it possible to read directly from the TCPStream to get an image if I know the size and all that, without first saving it to a memorystream? My code currently works with putting the first 4 byte in the TCP stream as a length for the entire data, so first I send the length. And then I know the length so I recieve it. ...
How can I make my library more flexible towards programmers? Here is my library. It's a basic library that provides a simple interface to organise your game (with scenes, and engine/game connection). The only problem that I dislike about it, is the fact that you cannot create a custom 'game loop', you must let the Game...
My code looks like imperative style code. I want to make my code more functional. How I can rewrite my program so it become functional style code? val _map = getMap(); if(_map.contains(x) && _map.contains(y)) Right(_map(x) + _map(y)) else if(_map.contains(x + y)) Right(_map(x + y)) else if(!_map.contain...
A picture says more than a thousand words, so here's a mock-up. The actual choices are different, this is just a sample. A user first has to choose between Red, Blue and Green. Upon selecting an option, additional form elements are displayed, depending on the choice. For Blue, a Date and Font are required. Currently,...