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
tef
May 30, 2004

-> some l-system crap ->
you're probably not going to get the api in your head first time, but writing hello world wouldn't hurt before the interview.

the thing really to focus on would be getting to grips with the differences with java, but for much of your code it isn't going to be much.

linq is probably the most useful and fun thing to play with

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
~ signed someone who has done a little java and had to read some c# a couple of times

fritz
Jul 26, 2003

coffeetable posted:

all i know is what i can remember from Under the Hood of .NET Memory Management, but:

thanks!

ShadowHawk
Jun 25, 2000

CERTIFIED PRE OWNED TESLA OWNER

bobbilljim posted:

lol if your ORM doesn't handle closing connections properly :smugmrgw:


*unfolds deckchair, sits back and watches*

python with: supremacy

Shaggar
Apr 26, 2006

tef posted:

at a guess.

- generics are different, no checked exceptions
- linq is hella neat.
- delegates are useful, as are extension methods. there is also using/idisposable.
- unsigned integers
- value types, nullable types


it's kinda lina a java with the bits that didn't work well or were used well removed, and some of the things that were missing that could be added because jvm compat wasn't an issue. but unlike another java descendent, scala, c# is for mortals

c# has a bunch of nice features that are super abuseable. linq, delegates, and extension methods being the top 3.

Shaggar
Apr 26, 2006
gonna write nothing but extension methods to Object.

CPColin
Sep 9, 2003

Big ol' smile.
At work we have piles of interfaces with a single method where everybody's implementation of it calls the same static method in a utility class and oh man I can't wait for us to upgrade to Java 8 so we can fix that

and then get closures and everything else wrong for a couple years

Workaday Wizard
Oct 23, 2009

by Pragmatica

Shaggar posted:

gonna write nothing but extension methods to Object.

everytime i use a third party library that add an extenstion method to string i want to rip the balls of whoever wrote it

the worst case i've seen is when the only way to create some object is through a string extension method, e.g. you can't new PieceOfShit("asss"), you must "asss".ToPieceOfShit().

BONGHITZ
Jan 1, 1970

what is the difference between ls and dir and why cant i use dir sometimes?

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

BONGHITZ posted:

what is the difference between ls and dir and why cant i use dir sometimes?

this isnt the windows RP thread

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

BONGHITZ posted:

what is the difference between ls and dir and why cant i use dir sometimes?

dir is a bad windows command ported to linux in an ill fated attempt to make cjs feel nostalgic for their window washing days

ls is a unix command that has served for over 30 years

Nomnom Cookie
Aug 30, 2009



tef posted:

well it's been a long while since i looked at java, so my memory is hazy, and it was off topic

but java didn't have dynamic dispatch originally, so i didn't think it right to lump it with the rubys and the smalltalks. under the scenes the jvm is doing lookup with fully qualified method names, although invoke dynamic confuses things a bit. and method handles.

there really isn't a meta object protocol, or a notion of sending a message, or symbols in Java, and in java you can access the attributes of an instance. it's sorta sorta structural, except that java doesn't really have functions yet*, so you don't have the whole x = obj.f; x() thing.

whatever. it wasn't really relevant to explaining the accidental? design around javascript's methods that sorta act like functions, and dynamic this.

i mean, who knows. the whole everything is bound to window by default was probably some quick hack to make a feature work. or functions were added first before prototypes were. i mean who knows what brendan eich was doing. iirc prototypes were included as a gently caress java.


* or whatever project coin and poo poo is happening

gonna have to nit you here and point out that the jvm deffo does do dynamic dispatch, that's the point of invokevirtual vs invokespecial. but it doesn't do late binding

Stringent
Dec 22, 2004


image text goes here

tef posted:

i have no idea what this metaphor means. i'm trying to explain the mechanics of a programming language design through it's interaction with other pieces, without going too far into detail.

was in reference to this http://www.theatlantic.com/politics/archive/2014/07/millennials-economics-voting-clueless-kids-these-days/374427/

coffeetable posted:

i don't see anything polarizing in that at all :confused:

nono, it was a good post it's just all tef's posts generate such a range of reactions

Blert the Duck
Sep 23, 2008

USSMICHELLEBACHMAN posted:

whoever posted this guys blog

http://duartes.org/gustavo/blog/archives/


thanks. i'm slightly less bad

same but i keep writing bad code instead of reading all his posts bc deadlines aaahh

says the guy reading yospos

Shaggar
Apr 26, 2006

Shinku ABOOKEN posted:

everytime i use a third party library that add an extenstion method to string i want to rip the balls of whoever wrote it

the worst case i've seen is when the only way to create some object is through a string extension method, e.g. you can't new PieceOfShit("asss"), you must "asss".ToPieceOfShit().

lol. owned. On the other hand, I wrote a bunch of extension methods to stuff like HttpRequestMessage like bool TryGetCookieValue(String key, out String value) and its unbelievably nice

double sulk
Jul 2, 2010

tef posted:

it's kinda lina a java with the bits that didn't work well or were used well removed, and some of the things that were missing that could be added because jvm compat wasn't an issue. but unlike another java descendent, scala, c# is for mortals

Scala makes me feel dumber than I already am and I don't like that.

Bloody
Mar 3, 2013

Shaggar posted:

c# has a bunch of nice features that are super abuseable. linq, delegates, and extension methods being the top 3.

idk id put var in the top 3

Shaggar
Apr 26, 2006
I've given up and started to use var now and then. whatever. i don't care.

Bloody
Mar 3, 2013

i just take a big ol steamy of var all over every code i write because im the only one who efver touches it so yolo

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

Bloody posted:

idk id put var in the top 3

i think resharper wants you to use var by default

tef
May 30, 2004

-> some l-system crap ->

Kevin Mitnick P.E. posted:

gonna have to nit you here and point out that the jvm deffo does do dynamic dispatch, that's the point of invokevirtual vs invokespecial. but it doesn't do late binding

:shobon: *cough* i get them mixed up sometimes

tef
May 30, 2004

-> some l-system crap ->

Shaggar posted:

I've given up and started to use var now and then. whatever. i don't care.

feels good man

Careful Drums
Oct 30, 2007

by FactsAreUseless
I used to be anti-var but then I realized var is nice because it functions as a code-smell.

Like, if I see `var` and I can't figure out the type without stepping into the other side of the expression, there is some room for improvement in the code.

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
var is the greatest and it's sad that i have to use java 1.3 instead of C#

Notorious b.s.d.
Jan 25, 2003

by Reene

bobbilljim posted:

var is the greatest and it's sad that i have to use java 1.3 instead of C#

holy poo poo, 1.3

what is going on at your employer

Shaggar
Apr 26, 2006

bobbilljim posted:

var is the greatest and it's sad that i have to use java 1.3 instead of C#

wowow. and I get upset I haven't had a chance to use 1.8

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I always use var when the type name is on the same line because String str = new String(); is dumb

Workaday Wizard
Oct 23, 2009

by Pragmatica
var cannot escape the scope of a function right?

Bloody
Mar 3, 2013

you can var wherever you like

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

Shinku ABOOKEN posted:

var cannot escape the scope of a function right?

you're thinking of anonymous types

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
"var" isn't a type, it means "infer the type of this variable from the expression on the rhs"

the statement "var x;" is not valid c#

Workaday Wizard
Oct 23, 2009

by Pragmatica
i was confused by

Bloody posted:

idk id put var in the top 3 [nice features that are super abuseable]

i guess if you deal with a 100 pages long function it might be hard but i've never had bad experience with var (i use it all day everyday ftw)

Bloody
Mar 3, 2013

i dont consider abuse of linq to be a bad thing

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
Never code for an embedded platform

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
"dynamic" is super easy to abuse in really fun ways

it's semi-trivial to write something that wraps any object and exposes its private/internal/etc members as public

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
also occasionally there are two very similar, but semantically different, types, either of which can be returned from a function, and you want one of the properties that's common

it's really nice not to have to write the same code twice

Bloody
Mar 3, 2013

bobbilljim posted:

Never code for an embedded platform

listen to this man

give me job security

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
I'm finally tired of being a lazyfuck. Gonna fix me some threaded gui poo poo. I also finally started getting lambdas and .NET's version of filter map reduce so I feel ambitious.

"Delegate to an instance method cannot have null 'this'. " loves to pop up if I call .StartWaiting() and then call .Endwaiting() too soon afterwards from the thread actually doing work. I don't know if the proper way to handle this is to force the thread calling the stop/start wait to itself wait (HEH) or wait on a message from the message box or what. This is my first time debugging threaded poo poo and isn't even my code.

Note this is written by a largely absentee guy who wears vibrams every day.

code:

Public Class GenericWaitWindow

    Private Shared Property ActiveWindow As GenericWaitWindow
    Private Delegate Sub DoneWaitingDelegate()
    Private Delegate Sub UpdateMessageDelegate(newMessage As String)

    Private Sub New()
        InitializeComponent()
    End Sub

    Public Shared Sub UpdateMessage(newMessage As String)

        Dim Callback As New UpdateMessageDelegate(AddressOf DoUpdateMessage)
        System.Threading.Thread.Sleep(100)
            ActiveWindow.Dispatcher.Invoke(Callback, newMessage)

    End Sub

    Private Shared Sub DoUpdateMessage(newMessage As String)

            ActiveWindow.c_Message.Text = newMessage

    End Sub

    Public Shared Sub StartWaiting()

        Dim Worker As New System.Threading.Thread(AddressOf DoStartWaiting)

        With Worker
            .SetApartmentState(System.Threading.ApartmentState.STA)
            .IsBackground = True
            .Start()
        End With

    End Sub

    Private Shared Sub DoStartWaiting()

            ActiveWindow = New GenericWaitWindow
        ActiveWindow.Show()
        System.Windows.Threading.Dispatcher.Run()

    End Sub

    Public Shared Sub EndWaiting()

        Dim Callback As New DoneWaitingDelegate(AddressOf ActiveWindow.Close)
        System.Threading.Thread.Sleep(100)
        ActiveWindow.Dispatcher.Invoke(Callback)

    End Sub

End Class



Yeah yeah I know vb.net whatever. If you're gonna mock it mock the loving thread sleeps :smithicide:

The code that then CALLS this does so like this:
code:
GenericWaitWindow.StartWaiting()

// stuff here

//loop starts
GenericWaitWindow.UpdateMessage(SomeMesageString)
//loop finishes and exits

GenericWaitWindow.EndWaiting()
Basically, what happened is if that loop never executes or executes very quickly, .EndWaiting throws the "yo what is this?" Earlier, the UpdateMessage would poo poo itself if I called it before I made a long call to a REST service; if I did so afterwards it had enough time to construct/pass around references/whatever is going on. But since I'd rather say "I am now downloading the nth thing in a list of things to download" than "I just finished the nth" I hosed with it and so did the Sr Dev on one of his rare days here. The Thread.Sleep idea was his.

But I no longer want to do such shameful poo poo. I'd rather fix this already.


Please help me unshit this code.

Shaggar
Apr 26, 2006
that is terrible. is this windows forms or wpf? why the hell are you starting a window in a new thread? what the hell is going on ?

Adbot
ADBOT LOVES YOU

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

Shaggar posted:

that is terrible. is this windows forms or wpf? why the hell are you starting a window in a new thread? what the hell is going on ?

Sr Dev: Hey do this
Me, having not done anything but MVC in a year: Sure!
*Sr Dev disappears for weeks again*
Me: WTF?

Would it be "how" of me to just do this again from scratch?

  • Locked thread