Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Here I wrote a quine for you:

code:

Adbot
ADBOT LOVES YOU

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
its funny because even in C# you still need to handle the exception when you open a file that doesn't exist, because someone could have deleted it after you checked for it but before you actually opened it

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
i write my random one-off scripts in perl because its practical

























extraction and reporting language

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Shaggar posted:

no. method calls should always have parentheses

yes, but what about functions? :smuggo:

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
object-oriented programming: for when you want to pass an agglomeration of random state into every single function but don't want to admit it

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
no the point is that what exactly is in "3 ounces of flour" is different depending on where in the world you are. so the quantity of flour you want to use in proportion to other ingredients can also vary.

also a recipe that uses eggs is not vegan

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
it's way easier to get a good job if you already have a job, even if your current job is kind of sucky. you also have the luxury of waiting until a good offer comes along instead of worrying about whether there'll be another one if you don't take this.

getting a job when you're unemployed / "working on your own projects" is p. hard in comparison.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
the easy way to think about it is "how does regular arithmetic work", then you think "how can i extend that to numbers bigger than a machine register"

if you really feel like it you can then think of faster ways to do those things, but that's not necessary if you're just after a working implementation

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
but enough about coding from the bathtub

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Squinty Applebottom posted:

sql is fine for what it is until you hit scaling issues and have to port your entire backend of a production app to something better

unless you're literally serving a million simultaneous connections your scaling issues are not caused by sql. and even then you can trivially shard it into a rw master and ro replicas.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
you should almost certainly try tdd if you haven't yet

you don't have to stick with it after you've tried it tho

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
If there's a 1:1 relationship then there's no need to have a separate foreign key at all, both models should have the same key.

Is there actually a many:1 relationship going on? If so, in what direction?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
There are reasons to want to use out or ref parameters, but Java doesn't have native support for them the way C# does. For that reason I'd recommend redesigning your code so that they aren't necessary. (Like, maybe return the new value instead?)

At the very least, your Variable class should use generics:

Java code:
public class Variable<T>
{
    private T value;
    
    public Variable(T value)
    {
        this.value = value;
    }

    public T getValue()
    {
        return value;
    }

    public void setValue(T value)
    {
        this.value = value;
    }
    
    @Override
    public String toString()
    {
        return "Variable<"+value.toString()+">";
    }
}
That said, like 99% of the time I've ever wanted something like this it's involved anonymous functions, and I've usually just used Atomic* because it already does what I want. I wouldn't stick it in a method signature though.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Why do you care what the code that actually accesses the db looks like? I mean yeah it's a shitpile of querying multiple tables and munging the results into some objects, but it's not like that interferes with your real code so who cares?

OTOH if that stuff is leaking into your business logic somewhere you done hosed up.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
there's really nothing wrong with making your native "application" just embed a webview control for its UI. CSS sucks, but it sucks less than a whole lot of other UI frameworks you might consider.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Shinku ABOOKEN posted:

can web ui do drag and drop and multiple selection yet??

e: sanely i mean

Drag and drop is really straightforward. You set the property that says an element can be dragged, and then you define event handlers on valid places that it can be dropped.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
The direct analogy to a shelfset would be the stash, but when actually working with git you typically use branches for most of the things you'd want a shelfset for anyway.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
my commit messages don't matter since it all gets pulled out into a single thing (with a new description) when it gets sent out for code review

the only person who sees them is me

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

b0lt posted:

also don't forget the part where a bunch of white people went "all rook same" at the characters and mashed them all together

i really want to know what the thinking was behind having three different code points for the letter o that are rendered identically, plus another dozen for "o in different fonts" (which you'd think would be better handled by having ... different fonts), all while mashing anything that looks even remotely similar in non-latin scripts into a single code point.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
but seriously as soon as i started reading that my question was "why the gently caress does everyone care what version the DEV database is using?"

like, just bring up your own database with some suitable test data when you're testing your local changes. then once that change actually gets to master the dev server gets the new configuration

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

pointsofdata posted:

there's a stylecop rule which says any use of #region is not allowed, which i don't really get. maybe that's why i'm in this thread!

Your IDE should be able to collapse sections of the file without needing to pollute the file itself with junk that everyone else has to deal with.

--

Also why the gently caress can't you just take your QA build and move it to production as-is? lol if you're manually merging things again to create your prod build, because now there's no guarantee that what was tested by QA is actually the same thing as what you're releasing.

Whoever is in charge of your release process has hosed up big time.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Space Whale posted:

The guy who did it is new to git. FWIW we all miss TFS. Maybe we can go back to it.

it's not even a git thing, this is just basic release management.

is the guy completely new to software development or something?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Valeyard posted:

a terrible programmer question, why does the regex,

code:
(-([a-zA-Z]+) )*
only match the latest (last) argument in a string like:

"-test -test1 -test2 test-3"

pretty sure that regex over the given input matches the "-test -test1 -test2 " part. the capturing group inside the regex, of course, will be filled in with whatever the value was the last time it matched - i.e. "test2".

what you actually want to be doing is write a regex that matches a single parameter and match it against the string multiple times use a library to parse command-line arguments instead of rolling your own bespoke system that doesn't handle things the way everyone expects

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

rotor posted:

just write your builds in shell or python or whatever scripting language you like because you'll end up doing it eventually so you might as well start it out cleanly instead of having 10 different build systems knit together with shell scripts

TBH this is probably fine if your project is small enough that you don't care about being able to do incremental builds

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

rotor posted:

there's nothing that prevents you from doing incremental builds in shell

you're going to write your shell script to check which dependencies need to be recompiled and only rebuild the things that do?

if you gently caress that up even once, someone wastes a bunch of time dealing with an "impossible" bug caused by not recompiling something that needed to be recompiled, and then no-one trusts your incremental builds anymore and wastes a whole bunch of time doing full builds because they at least know they'll be correct.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

FamDav posted:

then again why would you waste dev time on this

yeah that's kind of what I'm getting at. having a shell script that runs cc on all your source files is trivial, having one that does proper dependency tracking and incremental builds is basically reinventing <insert build tool here> except in a lovely bespoke form.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
when the costs are effectively nothing you can still make the claim "you should do at least this much" and be objectively correct.

you seem to think that people are also saying "but don't put any more effort into it than we do", when that's really not what they're talking about

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Serious question, how does code review (real code review, the kind where you have someone review and sign off on it before the code actually gets added to trunk) work with svn?

With git you have a branch with your proposed change and your reviewer looks at that and pulls it to the master repo if they think it's good. But it sounds like actually using svn branches is discouraged over on that side of things?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

suffix posted:

i have a terrible programmer question: how do you do dependency injection right?

i get the concept and how it makes unit testing easier, but on the projects i've worked on it always ends up with at least one of two problems:
- all your code ends up unnecessarily tied to a specific injection container
- your outermost layer ends up being a gigantic mess of instantiating and connecting every object in the program, maybe in xml for good measure

like 90% of the time we don't have any alternative implementations and only want to switch it out for our unit tests,
so it doesn't feel right to just pass it up until your main code has to care about a helper class to a helper class to a helper class,
but that's the logical conclusion from the introductory texts i've read

Guice (and presumably other "magical" DI frameworks, though Guice is the only one I'm familiar with) are really cool when you have the discipline to avoid shooting yourself in the foot with them. They make it really easy to shoot yourself in the foot, but if you can avoid that they're all good.

Basic rules are to avoid everything "clever" that the framework lets you do, only inject concrete classes, avoid scopes except for maybe singletons, don't use annotated injections to get multiple different things of the same type. Then it's basically just a way to instantiate objects without needing to know what their dependencies are (which is the whole point of a DI container rather than doing manual DI), while still being able to bind everything to mock instances etc. in your tests. Once you've wrapped your head around it enough to avoid making write-only spaghetti code, you can identify situations where a "clever" feature makes something less painful and won't make you regret it when you have to debug things later.

If you're doing it right then the only code that's actually tied to a specific injection container is the top-level stuff that configures bindings (which you won't have many of if you follow the basic rule and only inject concrete classes) and requests an instance of whatever object is the root of your object graph. Everything else just has an annotation that says it should be DIed and wouldn't need any changes if you switched to a different container for whatever reason.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
the code currently keeps track of the largest number it's seen so far in the aptly-named "largest" variable.

the experiment is asking you to add another variable (say, largestKind) that keeps track of what kind the largest number seen so far happens to be.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
you should post something that you've tried but isn't working - it's way more instructive to point out where your existing approach went wrong than it is to just give a solution (or a process to derive a solution) from nothing.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Single-implementation interfaces are dumb as poo poo. Yes, your class should have a sane public interface and you should stick with it instead of gratuitously adding methods all over the place. No, you don't really need a FooManager interface plus a FooManagerImpl class.

If you find that later on you do need multiple distinct implementations, you can refactor things easily enough.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Valeyard posted:

i get that its all to do with referncing but i still think one of those two approaches should work

i don't think it has anything to do with referencing

try printing out the values (and keys) as they get iterated over, and make sure they're what you expect

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Shaggar posted:

idk what postman is but its probably ignoring cross domain security. this is why people use jsonp for cross domain stuff. altho setting up cors support in webapi isn't hard

Ah yes, jsonp.

Also known as "I don't know how to configure my server correctly, so instead, how about anyone using my api has to give me the ability to xss their site at will".

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
same but to passive-aggressively point coworkers at

(actually my coworkers are all totally fine, I just wanted to make a joke about nerd stereotypes)

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

fart simpson posted:

what are promises and how are they related to and/or better than callbacks?

basically a 'promise' is an object that calls a callback when some operation has finished (or failed).

it has sensible semantics (like, if you say "hey call this function when you're done" on a promise that's already been resolved, that function still gets called instead of being forgotten about), and having a common api for every thing-that-calls-a-callback-when-it's-done means that you can get lots of cool utility functions to manipulate promises and avoid your async code turning into callback hell

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

triple sulk posted:

yeah just like commercials, which was supposed to be illegal now iirc but still happens anyway

i'm pretty sure they're not louder in terms of how many dB they are, they just use some funky audio processing to sound louder without breaking the law.

which is actually kind of cool but also kill all marketers

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
having the new guy work directly on the client's production database seems like a massive horror

actually, doing anything at all in production other than "roll out a new version" is highly suspicious. clone that stuff to a dev instance (if necessary) and work on it there.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

~Coxy posted:

3. unit testing (or to be precise, mocking) relies on you implementing an interface for the object you want to mock so get used to it. yes this is dumb.

not any more, thank god

we still have way too many single-implementation interfaces littering our code for precisely this reason, I try and delete them when I can because it really pisses me off

Adbot
ADBOT LOVES YOU

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

~Coxy posted:

what do you mean?
this is important

i know this is way late but any reasonable mocking framework will let you create a mock for a (non-final) concrete class. no need to use a single-implementation interface to be able to mock it out in a test.

  • Locked thread