« first day (1191 days earlier)      last day (3798 days later) » 
01:00 - 05:0005:00 - 23:00

user55340
5:00 AM
And then, you'd have instead of " <classpathentry kind="lib" path="lib/reflections-0.9.9-RC1-uberjar.jar"/>" ----- " <classpathentry kind="lib" path="/users/ampt/schoolwork/java/lib/reflections-0.9.9-RC1-uberjar.jar"/>"
 
user55340
And you really don't want to check that in... because it means when I check in my code you'd get a different path when I overwrite that file and your project would break.
 
user55340
(not bad, MSO question has +7 score on 17 views... and two of those views are me and google)
 
not bad at all
 
user55340
So... looking at the code and what not... you're putting a class in the map you return.
 
user55340
Why not take a parameter of the file you're opening and get back a WebFile instead?
 
5:06 AM
thats the goal. this factory would be reused over and over
you give it a file, it looks at the extension
and returns the appropriate WebFile
could be an ImageWebFile, HTTPWebFile, ZipWebFile
 
user55340
Allright... just making sure we're both thinking in the same direction there.
 
Some of the comments are from my prof about what needs to be done etc etc
 
user55340
(you're one of those people who doesn't put a space before his '{'?)
 
Mmmm I may have missed one, I usually do
 
user55340
one?
 
5:07 AM
none right after a ( though
or before the closing one
 
user55340
public WebFileFactory(){
 
user55340
for(Class<? extends WebFile> possibleMatch : subTypes){
 
apparently I don't put a space ever
 
user55340
if (annotated.contains(possibleMatch)){
 
user55340
You're one of those people.
 
user55340
5:08 AM
Space. Space. Space. I'm going into space. Space.
 
so am I totally off base?
or does what I'm doing make sense?
 
user55340
It does make sense.
 
its overkill, I'll admit to that
 
user55340
Debateable.
 
user55340
Yes, it might be overkill for 3 types. But on the other hand it is a good learning experience, and is the right way to do it.
 
user55340
5:12 AM
Sure, you're doing 3 types now... how many file types are there that you might implement in this some day.
 
yeah, that's the thought
 
user55340
You don't want to have a if block with 500 things in there.
 
user55340
This exactly goes back to that question you answered the other day here.
 
theres actually 5 types I have to service at the moment, but yeah, i could see it getting much, much bigger
 
user55340
With the time objects.
 
5:14 AM
ooh yeah
(had to look through my answers to find it)
its one of those things where I have no clue how big this could get
 
user55340
Thats where I've seen code that has nearly 1k if else if statements...
 
if the labs keep up at this rate, it could be 500 things by the end of the quarter
i could be playing movie files, dishing out exchange emails and hosting RoR projects lmao
alright, well that makes me feel better about what I'm doing
I haven't completely lost it yet. Time to celebrate with a beer!
Thanks @MichaelT
also, you know, if you wanted to make that maven build and put a pull request into the repo.....
;)
 
user55340
Give me a bit... you've got a.... non-standard directory structure for maven.
 
user55340
One of the things that maven does... it really likes things to be set up a certain way.
 
really? I thought that was a fairly simple one?
 
user55340
You've got src... but you need to split src/main from src/test
 
ooh, yeah src and test are both root level src directories
 
user55340
and then you've got src/main/java vs src/main/haskell or whatever...
 
odd....
maven is picky
 
user55340
It likes things in a very particular structure.
 
user55340
5:24 AM
But, when everything is in that structure, its quite easy to work with and things make sense there.
 
user55340
So, it wouldn't be a small change to your repo if I was to mavenize it.
 
well I'm open to change if you are, but I understand if it's too much haha
i was just reaching ;)
 
user55340
Try it with your next project though.
 
i will
 
user55340
There's an eclipse plugin for easier maven modifications... nice pages for modifying the structure.
 
5:29 AM
well, i need to hit the hay, but I really appreciate all the help @MichaelT
 
user55340
One sec... almost got it.
 
user55340
I think.
 
oh really?
 
user55340
This is part of it...
 
user55340
	public WebFile getFile(String fileName) {
		Matcher m = ext.matcher(fileName);
		if(m.matches()) {
			String g1 = m.group(1);
			if(theMap.containsKey(g1)) {
				try {
					return theMap.get(g1).getDeclaredConstructor(String.class).newInstance(fileName);
				} catch (Exception e) {
					System.out.println("FUBAR");
				}
			}
		}
		return null;
	}
 
user55340
5:30 AM
(yea, I've got it set up to be a tabist...)
 
user55340
haven't reconfigured it to be 4spacy.
 
user55340
But you see the essence of it there.
 
yeah
interesting
what is an ext.matcher?
 
user55340
Pattern ext = Pattern.compile(".*\\.(.+)");
 
user55340
Find the trailing dot and pull off the extension.
 
5:32 AM
ahhhhhh I see what's going on there
 
user55340
See how easy it is now?
 
so that would be the logic they would use to get the correct WebFile class
 
user55340
Correct.
 
They just have to have a constructor which accepts a string
Is there anyway to specify that in the interface or anything?
 
user55340
9
Q: How can I force a Constructor to be defined in all subclass of my abstract class

dodecaplexI have an abstract class A that define abstract methods. This means that, for a class to be instanciable, all the abstract method have to be implemented. I'd like all my subclasses to implement a constructor with 2 ints as parameters. Declaring a constructor defeats my purpose, as I want the c...

 
user55340
5:34 AM
You'd probably abstract class it instead.
 
user55340
And then put the constructor in the abstract class.
 
the constructor for....?
oooh newInstance
 
user55340
Instead of WebFile being an interface, make it an abstract class. Then have WebFile(String) be defined.
 
so the superconstructor needs a string and they can figure it out from there
that makes sense
 
user55340
But as it is, it will thrown an exception if there's no correct constructor at runtime.
 
5:36 AM
ok, that would work
 
user55340
The abstract class makes sense for this.
 
user55340
You've got common things you want to do with it and impmenet...
 
user55340
There is a File underpinning it.
 
implement
 
user55340
There's also things like get size of file.
 
user55340
5:37 AM
implement.
 
user55340
Its late.
 
gotcha
hahaha i know the feeling
that is perfect
 
user55340
(I had to turn up my thermostat - it was getting cold)
 
user55340
Btw, I just got my Nest Protects
 
user55340
Gonna replace my smoke detector this weekend!
 
5:37 AM
Next Protects?
what is that??
 
user55340
Nest - Company founded by former Apple people to make a really nice thermostat.
 
user55340
Think if head R&D from apple wanted to make a thermostat.. what would it do? look like?
 
maybe you should just be a better cook hahaha
 
user55340
 
user55340
 
user55340
5:39 AM
The outer ring turns, and pushes - you've got the interface.
 
user55340
And its on wifi so that it can find out what the temperature is outside and adjust / predict how long it will take to heat.
 
user55340
And I can control it from a device... arbitrary number of heating cooling points on the schedule.
 
haha wow
that is crazy with the features
 
user55340
The smoke detector can talk to the thermostat...
 
user55340
And so if it detects smoke and or carbon monoxide, it could do an emergency shut off of the furnace.
 
user55340
5:41 AM
 
user55340
Also, if it finds you keep turning up the thermostat at a certain time, it adjusts the schedule to match.
 
it has scheduling?
my thermostat has a temperature hahaha
 
user55340
Not only does it have scheduling, but it can detect if you're in the room.
 
user55340
Doesn't work too well for me - that feature... I'm up 1 floor from it.
 
user55340
So until I get zone control in my house, I can't use that bit...
 
user55340
5:43 AM
but when I do... I could have it so that it would keep the room I'm in heated/cooled properly while letting the rest of the house conserve energy.
 
user55340
 
be like bill gates and have it follow you from room to room
 
user55340
That's the heating from my house yesterday. The red was when it was on, dots are temp changes.
 
user55340
@Ampt It has a motion / ir detector in there to see if there's a person there.
 
put one in every room
 
user55340
5:45 AM
It can also detect if sun is shining on it and compensate for that.
 
user55340
@Ampt That's the zone system.
 
of course it supports that
 
user55340
Yep... oh, it also supports multiple houses.
 
user55340
Say you've got a cabin in the north woods with a nest there too.
 
.......
 
user55340
5:47 AM
And it detects you go to the cabin, it can tell the other one to go to away mode.
 
you've gotta be fuckin kidding me
does it make breakfast in the morning too?
 
it integrates with the vents as well?
are they iVents?
 
user55340
Nope... just itself. Half have to remember, this is strongly influenced by Apple.
 
user55340
 
user55340
5:50 AM
Look at Tony Fadell, Matt Rogers, Shige Honjo, Chip Lutton... but really, all of them.
 
Applers?
 
user55340
> Tony led the team that created the first 18 generations of the iPod and the first three generations of the iPhone. Before Apple, Tony built the Mobile Computing Group at Philips Electronics. Tony has authored more than 300 patents. He graduated from the University of Michigan with a Bachelors in Computer Engineering.
 
I dont recognize them
 
user55340
> Matt was responsible for iPod software development at Apple, from concept to production. He is passionate about mobile products, loves team building and rapid productization. Matt earned his BS and MS degrees from Carnegie Mellon University.
 
user55340
> Shige has more than 20 years of consumer electronics design, development, and execution experience on more than a dozen mobile phones and other products. Prior to Nest, Shige was the lead engineering program manager at Apple for several early generations of iPhone from concept to ramp. He received his BS in electrical engineering from Georgia Institute of Technology.
 
user55340
5:51 AM
They're not names to recognize... but when you read the 'about' it kind of sticks out that half the team is former Apple.
 
user55340
(Thats CEO, VP of Engineering, VP of Manufacturing)
 
user55340
(hmm... didn't realize that... the Nest Protect (smoke detector) can also act as a motion sensitive night light)
 
user55340
The odd bit is the amount of polish they put on things that people don't want to deal with - thermostat, smoke detector.
 
Yeah the design is ridiculously good for something I'm going to put on the ceiling
and probably never look at haha
 
user55340
It glows green each time you turn out the lights for a bit to let you know it passed its self check.
 
user55340
5:56 AM
(no high pitched chirp in the middle of the night)
 
ugh that drives me nuts
 
user55340
(the chirp - not the video for anyone looking at the transcript)
 
yes... the... chirp
Go to bed @MichaelT haha
 
user55340
Watch that video.
 
6:08 AM
That is awesome.
 
user55340
Yep - its really neat / uplifting... the things that technology can do for the betterment of society.
 
user55340
(I'll toss a pin on it for a bit... just so it doesn't slide off right away)
 
user55340
Anyways... yea... sleep.
 
user41796
2:24 PM
@MichaelT - Nest is an awesome company with a crazy passion for their devices. One of my friends runs one of their programming teams. The Apple influence is huge (many are former Apple) and the two companies are on great terms with each other. They're also growing like crazy too.
 
4:23 PM
@MichaelT good call on the pin. I would have if i could. I pulled GF aggro halfway through that video but managed to get her to let me finish it before she made me turn the computer off haha
 
4:39 PM
Hi guys, I asked a question here, and they told me it would be more suitable for chat, would it be allowed to link to it here?
 
user55340
@DylanKatz certainly - just paste the URL in a message by itself to one box it. Realize this is the weekend and we don't quite have the same traffic compared to the week.
 
1
Q: Is it wrong to feel intense emotions after a release?

Dylan KatzI just released a project, and I'm still trying to get over the emotions. I've felt deeply sad, angry, insecure, and happy(not in that order necessarily), all within a few days. I don't believe it's an ongoing disorder, as It's only been centered around my project. So my question is, Is it normal...

 
 
2 hours later…
6:27 PM
big data question:
What do you call it when a distributed database uses two copies of the same data on different nodes to be more robust?
 
redundant?
 
I mean, is there a name for this pattern/architecture
?
 
uh oh.. don't use the p word around these parts
you're liable to get a face full of monads
I'm not sure, I'm not into big data
 
 
3 hours later…
user55340
9:07 PM
@Ampt got a patch file for you...
 
@MichaelT oh really?
 
user55340
Yep.
 
You have my attention. i'm currently struggling with it right now
I have to support real HTML files, virtual files (generated on request) and 404s
 
user55340
Actually, its small enough I could put each file up one at a time here without spamming anyone.
 
you want me to add you to the project?
either works for me
 
user55340
9:08 PM
Nah... probably easier this way too.
 
user55340
package server;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.reflections.Reflections;

public class WebFileFactory {
	private static Map<String, Class<? extends WebFile>> theMap;
	private static final Pattern ext = Pattern.compile(".*\\.(.+)");

	static {
		Reflections reflections = new Reflections("server.fileTypes");
		Set<Class<? extends WebFile>> subtypes = reflections.getSubTypesOf(WebFile.class);
 
ok, go for it
 
user55340
That's the factory.
 
user55340
Its all static, with a static block to set up the data structures.
 
didn't know you could do that
 
user55340
9:10 PM
Fetch the classes that are subtypes of WebFiles. Verify the annotation is present, cast it to the annotation, and then fetch the data from the annotation.
 
user55340
One of the classic 'trick' questions in Java interviews is "how many ways can you use static
 
user55340
And in this class, you see 3 of them... the static {} is just something that is run when the class is loaded.
 
I actually grabbed both the annoted and all the subclasses
then compared the two lists. if a class was on both, its good
 
user55340
Either way... it does the same thing.
 
yours is more elegant haha
 
user55340
9:11 PM
I grab all subtypes and filter it.
 
user55340
(You're seeing the 'years of experience' and the desire for elegant code)
 
user55340
And then you've got the factory part in getFile that takes a fileName as a string.
 
haha yeah pretty much
my approach was more "I think this will work..."
 
user55340
It pulls the extension of the file name off and then finds the matching item in the map.
 
ok, so heres a question for you then; I have to support those 3 types of HTML files
how would I go about that?
I was thinking strategy pattern inside of the HTML class
 
user55340
9:12 PM
package server.fileTypes;

import server.Types;
import server.WebFile;

import java.io.File;
import java.util.List;

@Types ( knownTypes = {"txt", "text"} )
public class TextFile implements WebFile {
	public TextFile(String file) {

	}


	@Override
	public WebFile createWebFile(File f) {
		return null;
	}

	@Override
	public List<String> getFileTypes() {
		return null;
	}

	@Override
	public String getStatusLine() {
		return null;
	}

	@Override
	public String getEntityHeader() {
		return null;
 
user55340
There's the TextFile class.
 
user55340
You'd implement that constructor.
 
user55340
Really, thats were the magic would all happen.
 
user55340
The annotation, I put some more enforcement on it so you can't annotate the wrong thing, and also that it shows that is available at runtime.
 
user55340
package server;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Types {
	String[] knownTypes();
}
 
user55340
9:14 PM
And then to make sure it all works... a unit test.
 
user55340
package server;

import org.junit.Test;
import server.fileTypes.TextFile;

import static org.junit.Assert.assertTrue;

public class WebFileFactoryTest {
	@Test
	public void testGetFile() throws Exception {
		WebFile file = WebFileFactory.getFile("foo.txt");
		assertTrue(file instanceof TextFile);
	}
}
 
ooh i like that
 
user55340
Make sure that each type of file gets the right file type back.
 
i was wondering how to do the unit testing properly... not a lot of experience with that either
 
user55340
And you see how they all fit together nicely now?
 
user55340
9:17 PM
And that factory is just a nice, small, tight class.
 
I actually remove the getFileTypes() method from the interface
the annotation did that
 
user55340
Yep.
 
why the retention and target annotations?
on the cutsom annotation?
 
user55340
Target keeps you from accidentally annotating a field or package or something else.
 
user55340
Its not that you need it, but it makes sure you can't put it in the wrong place thinking it will do something.
 
9:19 PM
oooh ok
 
user55340
Same type of thing of "why don't you make everything public" - well, its because the tighter the constraint on the thing, the harder it is to misuse it.
 
user55340
The runtime, I'd have to double check... but not all annotations are available at all times - some are compile time only, some are runtime only. I'd need to check on the default.
 
user55340
@deprecated is compile time only for example.
 
user55340
> public static final RetentionPolicy CLASS
Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time. This is the default behavior.
 
user55340
There you have it, unless you put that on the annotation, you won't be able to find it at runtime.
 
user55340
9:24 PM
Oh, here's another fun bit... the 4th use of static...
 
user55340
import static org.junit.Assert.assertTrue;
 
user55340
Pulls the assertTrue directly into the namespace so that you don't need to specify the package when invoking it.
 
iiinteresting
ok, so I figure out whether its generated, real or 404 when I create the HTML file
so there should really be only one HTMLClass which implements the interface
wow, lot of homework questions on the list today
 
user55340
When you try instantiating the WebFile object, have a 'status' method of some sort (takes an argument of authorization in case you ever need the 403). It returns an eunm of OK, FORBIDDEN, or GONE
 
user55340
The factory then either returns the WebFile if its OK or the associated error file for the other situations.
 
user55340
9:30 PM
If there's an internal error in trying to do this, it returns a SERVER_ERROR (500) page.
 
user55340
You could make another factory method/setup for the error pages.
 
user55340
ie: server.specialPages.Gone and server.specialPages.Forbidden
 
user55340
These would be annotated to make use of the associated enum (rather than a string).
 
user55340
So... think up more questions. I'm going to go get some weather stripping for my door (found a draft).
 
yeah i was thinking about a second use of reflection
ill come up with an architecture and run it by you tomorrow
 
user55340
10:16 PM
@DylanKatz been thinking about this a bit...
 
user55340
(for any other readers, to catch up)
 
user55340
1
Q: Is it healthy to feel intense emotions after a release?

Dylan KatzI just released a project, and I'm still trying to get over the emotions. I've felt deeply sad, angry, insecure, and happy(not in that order necessarily), all within a few days. I don't believe it's an ongoing disorder, as It's only been centered around my project. So my question is, Is it health...

 
user55340
You might want to read melaniecossey.com/apps/blog/show/… which is about selling a painting. Programming isn't unlike the arts in where someone sells the work they created... releasing being similar to selling in many respects.
 
user55340
> He made the comment that when he sells a painting it "hurts my heart."
 
user55340
 
user55340
10:19 PM
The completion of a project is a time of uncertainty. What will you work on next. These things do manifest themselves as emotions and other emotional tumult.
 
user55340
And so, its not unexpected. However, the "is it healthy" question is one that no one here (even those that work in health care software (joking)) can properly answer - thats something for the medical profession to answer.
 
01:00 - 05:0005:00 - 23:00

« first day (1191 days earlier)      last day (3798 days later) »