It is essentially treating yield in a unique way - I tried converting the code to Es6 to see if it would work, but the code printed 'undefined' (as expected)
That leads me to think that SpiderMonkey versions 18 through 24 had people experimenting on yield, which makes sense, because yield was not defined in the ES5 spec and was therefore undefined behaviour
In the same way that dereferencing a null pointer might work fine, or might just burn your house down
@EBrown I would personally recommend treating 'messages' as just bags of data and having an interface consume those messages to do something with them.
// Implementations define what they need in their constructor
interface IMessageHandler<T> where T: IMessage {
Task Process<T>(T message);
}
// The POCO
interface IMessage {
string Name { get; }
}
// When server receives a message, it publishes an even
// Then somewhere you need to have the message handler do something like
//
server.On("Foo", new MyMessageHandler<FooMessage>());
class MyMessageHandler<FooMessage> : IMessage<FooMessage> {
MyMessageHandler(PlayerService playerService) {
This is a challenge question from codeeval.com
Write a program which reads a file and prints to stdout the specified
number of the longest lines that are sorted based on their length in
descending order. Input sample:
Your program should accept a path to a file as its first argument....
So, as it stands now, my IDataMessage interface would need an additional Process(ServerConfiguration config, ServerState state) method. Which each of those parameters would have some effect on how it processed the messages.
The IDataMessage HandleMessage(NetIncomingMessage message) would still need that large switch statement, so that it could build the proper messages. But the ProcessDataMessage(NetIncomingMessage message) would not need one. It would just call messageResult.Process(config, state).
It's up to you. LoginMessageReceived is less backwards compatible than MessageReceived because you would need to add a new event for every message received
You would IMO quickly get a monolith with that pattern.
MessageReceived allows you to not do that, however it might make following the code a bit harder.
You are aware that a massive list of events is going to be a massive block of code that you cannot move, right? ;-)
you can handle each event in their own class regardless of whether you have an event that publishes every message or one event per message, that's moot
Well, if I were doing events I would prefer to make many events that are verbose of their meaning, than one event and having to wonder which method implements which portions of that event.
In object-oriented design, the chain-of-responsibility pattern is a design pattern consisting of a source of command objects and a series of processing objects. Each processing object contains logic that defines the types of command objects that it can handle; the rest are passed to the next processing object in the chain. A mechanism also exists for adding new processing objects to the end of this chain.
In a variation of the standard chain-of-responsibility model, some handlers may act as dispatchers, capable of sending commands out in a variety of directions, forming a tree of responsibility...
This is prim's implementation! Indeed this is very complex and slow and a better version is here but I still want to know the time complexity of below code. You can check the same code here too nice colors and indentation
#include <bits/stdc++.h>
using namespace std;
const int size = 12345;
i...
Right now I can only implement the Cartesian Product of two collections, here is the code:
public static <T1, T2>
Collection<Pair<T1, T2>> getCartesianProduct(
Collection<T1> c1, Collection<T2> c2,
Collector<Pair<T1, T2>, ?, Collection<Pair<T1, T2>>> collector) {
return c1.st...
I have created three layers on an Express based REST API.
The first layer is Express Controllers that are basically functions that accepts req, res, next.
Those controllers are always dealing with the next layer which is the Services. Services are wrappers around Mongoose models and provides ba...
The aim of this code is to produce dictionaries of probabilities of words given tags(called emit here in my code) and tags given tags (called trans in my code) and each dictionary and also the tags which were used in the corpus are saved in separate files. But there's a key error and also there i...
This is a Prim's implementation! Indeed this is very complex and slow and a better version is here but I still want to know the time complexity of below code. You can check the same code here too nice colors and indentation
#include <bits/stdc++.h>
using namespace std;
const int size = 12345;...
I am writing a Python script that creates a customized, efficient adblocking hosts file. Basically it checks the user's DNS cache and sees if any entries there are listed in the popular hosts files. If so, it adds those entries to the user's hosts file. The purpose is to keep the hosts file sm...
So... in theory I could make a bot, feed him text from The 2nd Monitor as input data, and let him say something every once in a while, and it would still make sense
As it "counts occurrences" it will often say "PHP is crap" and very often say "Java is crap"
This code removes any middle point find in line. It works only in x and y axis. This problem is JAVA implementation of http://www.geeksforgeeks.org/given-linked-list-line-segments-remove-middle-points/
package com.atleyvirdee.myDataStructures.linkedlist.problems;
import com.atleyvirdee.myDataS...
Please could someone help me with cleaning all this code up... and making sure everything I have done is as efficient as possible? There is just a menu-bar at the top of the page... and image in the background with a title over the top of sed image. The menu is dropdown when you hover over "HOME"...
Meme: Yet another linked-list (also nooooooooo)
Originator: skiwi
Cultural Height: The apparent popularity of linked list implementations
Background: The site has received a lot of linked list questions with more coming in over time. It has also led to many duplicate titles and even some dupl...
I'm writing a neural net which uses a genetic algorithm to adjust the weights. To represent possible range of "genes" for the GA, I'm passing in a list of bases. Unfortunately, I realized after the fact that there will be a huge possible range of weights for the net, and storing a list of all pos...
It is impossible for me to reproduce your problem unless you either give me a link to your entire code base, which means you should probably post your question to code review, or you reduce your problem with the simplest piece of code possible to reproduce the issue you are having. Again, I'll link this article for helpful information on this. — John Carpenter39 secs ago
I have written a simplified version of my own MyConcurrentHashMap. I tried to make use of a Lock[] array for Lock striping, so that all put() operations to the MyConcurrentHashMap is through a lock if required. Also, I made my own MyHashMap made internally as the backing data structure for MyConc...
I have a IRC bot that I'm writing (code is here, bot24-irc.py is the main module).
This bot needs to be able to perform many different, separate roles so that each can be reloaded and sandboxed (for stability). I'm defining a role as being a function that reads all PRIVMSGs sent and returns a li...
This is a challenge question from codeeval.com:
Write a program which reads a file and prints to stdout the specified
number of the longest lines that are sorted based on their length in
descending order. Input sample:
Your program should accept a path to a file as its first argume...
Beta Q&A site for feedback on projects you're working on, by sharing your code with fellow programmers and getting extensive feedback/review of best practices, design pattern usage, application UI, security, etc.
Beta Q&A site for feedback on projects you're working on, by sharing your code with fellow programmers and getting extensive feedback/review of best practices, design pattern usage, application UI, security, etc.
I'm writing a question about a patch I'm writing to a GPL project. Is it okay to include a bit of code I've not written myself as context? I'll paste the copyright notice from the source file.
Is it a legal issue to post someone elses code? From Stack Exchange TOS:
> You agree that all Subscriber Content that You contribute to the Network is perpetually and irrevocably licensed to Stack Exchange under the Creative Commons Attribution Share Alike license.
Maybe it would work better if I put it in a Gist/Pastebin?
@jacwah If it's copyright code, you should post a link to the code itself, if published. If not, I'd leave it out entirely, unless you have the author's permission
OK. I'd suggest just including a link to the repo. GPL2 is not far off from CC-SA, although CC is more commonly used for media content (as in, the content of the post becomes media under CC, regardless if it's code or not)
Do you really need a comment above every line? There are a few good comments like # Function to retrieve current timestamp, hopefully using window.performance object, but comments like # Indicates if module is running are really not useful. They add no value to the code itself, and can b...
I am currently reading about the thread-safe implementation of a linked list. I would like someone to point out some mistakes that will create issues if I try to make it thread-safe in the future.
Information:
Please review the SinglyLinkedList mainly.
You may Point out any Design issue in cl...