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
Gul Banana
Nov 28, 2003

Jabor posted:

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.

I've got a colleague who went through everyone's machines and changed the visual studio templates to create sealed (c# for final) classes by default
lots of IInterface in that code.

Adbot
ADBOT LOVES YOU

Gul Banana
Nov 28, 2003

Bloody posted:

ctps: T4 is amazing but why the gently caress doesnt visual studio's editor give it any more support than notepad does

use this

Gul Banana
Nov 28, 2003

FamDav posted:

I'm vibing on elm.

vibing HARD

i was all excited by elm and i started trying it out. elm-html seemed like a great way to write html, so i did some demo stuff and it turned out that you're still putting together freaking html
basically it made me miss XAML.

also, the Elm Architecture paradigm seems a little.. undercooked? it's impressive, but you run into stuff like.. why isn't there a built in way to have 'child' components, the state of which you update whenever you update your own? & the conceptual issue of, is a foldp over your entire set of inputs really, really a sane thing to do? really? all the buttons on a page and everything someone could press or click or drag or.. that should *really* be a single type/handler? r e a l l y ?

Gul Banana
Nov 28, 2003

~Coxy posted:

I wish they would hurry up with VS2015 so I can get EAC back :unsmith:

we're using the RC rather than wait for that v_v

Gul Banana
Nov 28, 2003

please use var all the time. use var for every single variable, except that one weird edge case where you need to contextually type a generic lambda from the outside. everything else though

Gul Banana
Nov 28, 2003

why not. what's wrong with being able to build the source you just checked out

Gul Banana
Nov 28, 2003

NihilCredo posted:

Doesn't apply to subclassing library classes, but what I do is, I put subclasses in the same file as the base class.

1) If the result looks or feels wrong, they probably shouldn't be subclasses

2) Because of 1), you're unlikely to go crazy with many levels of inheritance

3) Easier to make sure you aren't breaking any derived classes when you need to change something in the base class

alas, the Expression Problem

Gul Banana
Nov 28, 2003

abraham linksys posted:

also i'll say this: the semantics around es6 modules are actually really good, they support circular dependencies and the default/named bindings system lets you make clean public APIs easily

yeah I thought so too until I tried to create a library of code for consumption by apps

it is literally required that modules correspond to actual source files. got 3 functions and a class? ok, put them in the same file. now you've got 60 classes because you're doing something nontrivial, and want to follow standard organisation principles like "each class goes in a file"? well, that's going to be 60 modules. which is, from the consumers pov, 60 different libraries in a dependency tree

obviously this is untenable so you have to pre-bundle them, which requires you to use webpack or rollup or something on TOP of es6 modules, then reexport the result AS a module, with an embedded freaking module loader runtime

Gul Banana
Nov 28, 2003

if you ask how to incorporate multiple files into a module on stack overflow, you get TC39 committee members and MS Typescript developers posting "why would you want to do that".

Gul Banana
Nov 28, 2003

what I want is for client code to get access to e.g. 10 different types or free functions from my libraries, without having to write 10 different import statements.

optional but also highly desirable: shipping a file rather than 60 of them. my colleagues do not know or want to know what webpack is (I write internal libraries for enterprise, so basically my job is to be the guy who knows what webpack is)

Gul Banana
Nov 28, 2003

yes, I'm doing something like that using rollup and typescript. (used to use webpack but it wasn't as good at tree shaking and required me to generate boilerplate reexports). basically the os I'm calling a pos in this case is the need to use multiple layers of tools and conventions atop es6 'modules' to get usefully module-like behaviour.

Gul Banana
Nov 28, 2003

fleshweasel posted:

how does the compile time for rollup compare to webpack
and how about the configuration process

both compile times are 'less than typescript's type checking so i don't care'. with one random project of ~30 .ts files the total compile time is about 10 seconds cold and <1 second when in watch mode or webpack-dev-server
rollup is easier to configure because it does less stuff, but it does have the same infuriating 'preset' packages system as babel 6

Gul Banana
Nov 28, 2003

have any of you people seen a business. or a user
linux doesn't work so well when you have users

Gul Banana
Nov 28, 2003

the reason that web 'development' is so big now is as a compromise between programmers who want to use Linux and users who refuse. so they write programs that run on linux but have a client for usable operating systems. except it turns out to make actual applications you need a lot more client side functionality, so everyone gets tricked into using javascript - but don't worry, that too has now been made a linux thing.

Gul Banana
Nov 28, 2003

idk if dragging a .app out of a .dmg is really nightmarish. running msis is less nice but that's why it's automated via group policy

when developers say that desktop deployment is hard they don't mean that it's difficult. they mean it has friction and therefore low conversion rates - that people are less likely to download an exe than to click through a link. this is perfectly true, but it's a marketing concern and has nothing to do with whether a program is actually good.

Gul Banana
Nov 28, 2003

fortunately, in the world of who use computers to do work everyone has domains, group policy etc already. this is the case despite licensing costs because linux is so totally unusable that 99.some number of 9s% of businesses have paid the extra to not use it.

Gul Banana
Nov 28, 2003

actually at my company we more often ship "a folder with an autoupdating exe", but we do msi builds for clients that prefer it. tends to come down to how they prefer updates and access control to be done.

Gul Banana
Nov 28, 2003

Notorious b.s.d. posted:

ok so you have all your users personal devices on the domain, managed by group policy?

oh, not at all. but I'm writing software people get paid to use, so they don't want it on their personal devices. the web is a brilliant distribution mechanism for applications where your users are the product rather than the client.

Gul Banana
Nov 28, 2003

Notorious b.s.d. posted:

so you ship an artifact and leave it to your poor bastard clients to figure out what to do

that's the easiest deployment scenario in the world right there: throw it over the fence, let the schmuck on the other side deal.

it IS easy, but fortunately it's also very common and exactly what people want.

Gul Banana
Nov 28, 2003

tbh if you've never worked in the business software industry ("lob", "enterprise", etc) it might be startling just how well aligned the incentives are for everyone. this stuff is where IT brings huge productivity boosts *without* also destroying the rest of the economy

it also employs even more people than Silicon Valley, thank goodness. Windows dominates but like eschaton says corporate stuff works quite well on Macs too. it's only Linux that's entirely out of the running - unless, again, developers persuade some poor client to let them write a webapp

Gul Banana
Nov 28, 2003

As a Millennial I posted:

in my experience you gotta load the PDBs from that very build. idk why. is it non-deterministic or something??

.net framework builds are deliberately nondeterministic yeah (it adds a timestamp)
.net core is changing this

Gul Banana
Nov 28, 2003

Powerful Two-Hander posted:

also serious question, what are the pitfalls of upgrading a solution from .net4 to 4.5? I've donw it, it builds, nothing is obviously wrong but i thought this was supposed to be one of those "this will gently caress up" upgrades so I'm convinced there's some nasty problem waiting to surface (its my code)

- doesn't work on Windows XP (hopefully you don't care)
- if you used wpf highlightbrushkey resources to customise datagrids the semantics have changed slightly
- may need to rerun aspnet_regiis

mostly it just works. it's also something you can do project by project if you want to, there's no need to switch over everything at once.

Gul Banana
Nov 28, 2003

Illusive gently caress Man posted:

o I thought people were advocating declaring literally everything using var

i advocate and practice it. what now

Gul Banana
Nov 28, 2003

hackbunny posted:

docs are not real. they aren't required to match the code or even be self-consistent. I'd rather have a test suite

also, most of the code in your project was written by your coworkers not a vendor. they didn't write any docs and if you did you KNOW not to trust them

Gul Banana
Nov 28, 2003

Condiv posted:

today i learned how to define a list that holds objects that implement a specific typeclass in scala

code:
// my typeclass
trait Buttlike[A] {
	def touchIt(a: A): String
}

//wrapper to smuggle the type in, thanks type erasure
case class Ev[TC[_], A](a: A)(implicit val ev: TC[A])

class BigButt

class TinyButt

//implementing the typeclasses for the butts
implicit object BigButtIsButtlike extends Buttlike[BigButt] {
	def touchIt(a: BigButt) = "fart"
}

implicit object TinyButtIsButtlike extends Buttlike[TinyButt] {
	def touchIt(b: TinyButt) = "poo poo"
}

//my list!
val l = List(Ev(new BigButt), Ev(new TinyButt))

//gonna touch those butts
l.map(_ match { case e @ Ev(a) => e.ev.touchIt(a)}) //List("fart", "poo poo")
:lsd:

man this just makes me want to use Rust

Gul Banana
Nov 28, 2003

real imperative-lang typeclasses:
code:
//typeclass
trait Foolike {
    fn foo(&self) -> String;
}

//structs
struct Bar;
struct Baz;

//implementations
impl Foolike for Bar {
    fn foo(&self) -> String { "foobar".into() }
}
impl Foolike for Baz {
    fn foo(&self) -> String { "foobaz".into() }
}

//touch the butts, metaphorically
let l: Vec<Box<Foolike>> = vec![Box::new(Bar), Box::new(Baz)];
let ls: Vec<String> = l.iter().map(|f| f.foo()).collect();

//prints ["foobar", "foobaz"]
println!("{:?}", ls); 
but i admit while writing the code i had to mess around and google stuff to get object-safety for the trait.

Gul Banana
Nov 28, 2003

gonadic io posted:

No, the Box just means that the value is allocated on the heap. In this example it's not necessary, you can just use a reference to a local variable instead.

that's right, Box is like c++'s std::unique_ptr. i used it so that the vector owned its butts, rather than having them on the stack (also to be one line)

Gul Banana
Nov 28, 2003

git filenames are a huge pain on windows also
it will happily add both path/thing.c and path/thing.C to the repo. guess what happens when you check that out on NTFS

go on, guess. because I certainly don't know, except that it's bad

Gul Banana
Nov 28, 2003

why would you NOT wrap it. it's an abstraction common to lambdas, fps, other callables etc and the only overhead is on call (irrelevant if the function does work)

Gul Banana
Nov 28, 2003

Space Whale posted:

also switch case in vb.net is loving retarded

You don't do poo poo lke this
code:
Select Case value
	    Case 99
            Case 100
		' Both 99 and 100 will end up here.
		Console.WriteLine("99 or 100")
	    Case 101
		Console.WriteLine("Not reached")
	End Select
you do this

code:
Select Case value
	    Case 99, 100
		' Both 99 and 100 will end up here.
		Console.WriteLine("99 or 100")
	    Case 101
		Console.WriteLine("Not reached")
	End Select
this seems better
switch-case is not exactly the highlight of C-style syntax!

Gul Banana
Nov 28, 2003

KidDynamite posted:

nah man someone paid for those xamarin licenses we HAVE TO USE IT

xamarin is free now ;_;

Gul Banana
Nov 28, 2003

Mr Dog posted:

I have a question about paging results sets returned by a REST server.

Let's say I'm writing a REST service. Clients can request a large list of rows, and the server will return a few initial matches along with a link where the client can find more (the link's query parameters contain all of the state required to resume the iteration), the target of that link contains more results and another link and so on. This is all well and good, except there's a problem if any other clients come along and insert or delete rows behind the client's current position: inserting a new row will cause the next page to start with a repeat of the previous page's last row, which might not be so bad, but deleting a row will cause the client to skip one record, which kinda sucks. Statelessness in the REST server is the name of the game here so the server isn't going to keep a long-running database transaction open for the client.

[..] I'm sure this is a problem that was well understood and solved before I was even born, but I can't find any meaningful answers with a bit of casual Googling. Most articles about pagination in REST APIs seem blissfully unaware that this problem even exists.

it is indeed a solved question, but the answer is that stable querying isn't stateless. there's maths about it somewhere. it's a classic ACID question - you want consistent, isolated reads. so the solutions are the kind of things sql servers do. snapshots copy id list to a table), transaction ids (mark stuff not-yet-deleteable), atomicity (ditch paging..)

efficiency stability and statelessness are a pick two thing, you could retain high perf but give up consistency in the face of deletes/inserts, stream/batch All data and defer to the isolation mechanisms of the data store, or keep server side state.

Gul Banana
Nov 28, 2003

Shaggar posted:

if your code is like

C# code:
var result1 = await client.DoRequestAsync();
var result2 = await client.DoRequestAsync();
iirc the execution order of the awaited calls is not guaranteed, it just guarantees that both requests will be done before their results are used. async/await is fancy syntax for futures/callbacks.
this is wrong. the order is guaranteed.

uncurable mlady posted:

yes, await blocks on the caller

this tripped me up a while ago

also incorrect; the caller is suspended by the execution context. there's no blocking involved

Gul Banana
Nov 28, 2003

async is not syntax sugar for callbacks. it's syntax sugar for a state machine. when you write a method like
code:
async Task<int> f() {
  a = await foo.x();
  b = await bar.y(a);
  return b + 1;
}
then the generated IL corresponds to something like this (much simplified):
code:
class f_machine<int> {
  int state;
  Task waiter;
  int _a;
  int _b;
  int _result;
  Task MoveNext() {
    if (state == 0)
    {
      waiter = foo.x();
      return false;
    } else if (state == 1) {
      _a = waiter.Result;
      waiter = bar.y(_a);
      return false;
    } else if (state == 2) {
      _b = waiter.Result;
      _result = _b + 1;
      return true;
    }
  }
}

Task<int> f() {
  var machine = new f_machine();
  while (!machine.MoveNext())
  {
    context.yield(machine.waiter); // this returns when the current task is ready and f() can move on
    machine._state++;
  }
  return Task.FromResult(machine._result);
}
it's quite a bit more complicated in reality; it doesn't use Tasks internally and there's a methodbuilder thing which registers with the ExecutionContext and is run in steps. here's an example of how to grab the real generated code and operate the machine 'by hand': https://gist.github.com/gulbanana/5d2e2291a42e717ce73d12d2f19c8306

Gul Banana
Nov 28, 2003

HoboMan posted:

someone on the team is extremely excited about this new language "typescript" they've been reading about

typescript is a major improvement on javascript IME

it's not really a "new" language though. just what it says on the tin - a type-checked version of js. for big projects that can make all the difference

Gul Banana
Nov 28, 2003

eschaton posted:

CJ Date wants to fight you, he says any use of NULL in a database means you modeled the problem improperly

he says you need to just do further normalization of anything that could be NULL

what about the problem "old versions of the system did not have this column"

Gul Banana
Nov 28, 2003

i don't think my ORM is going to see much difference between a null resulting from a join and a null present in a column.

Gul Banana
Nov 28, 2003

Bloody posted:

why do my unit tests occasionally just halt with no given reason
not abort, not fail, just halt. stops everyone else from executing too. wtf

that means the tests are failing so badly it's crashing the runner process and it can't even report what the error is
debug the tests with break-on-exceptions on

Gul Banana
Nov 28, 2003

there is an interpreter which runs .rb files
i don't think it JITs them or anything, it's pretty slow

Adbot
ADBOT LOVES YOU

Gul Banana
Nov 28, 2003

GameCube posted:

i have crawled waaaaaaaaaaaaaay up my own rear end in a top hat
code:
public static IEnumerable<Tuple<IEnumerable<Mome>, IEnumerable<Chome>>> Lomarf(IEnumerable<IEnumerable<Mome>> momes, IEnumerable<IEnumerable<Chome>> chomes)
this is for a unit test

we really need some syntax sugar for what shoulda been core builtins there. 'public static [([Mome], [Chome])] Lomarf([[Mome]] momes, [[Chome]] chomes)' would look fine

  • Locked thread