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.
 
  • Post
  • Reply
Rooster Brooster
Mar 30, 2001

Maybe it doesn't really matter anymore.
The best description I ever heard of a ViewModel was "a value converter on steroids". It's meant to take in a whole bunch of model data and turn it into a form that's easily consumable by some View. Definitely not necessarily 1-1 with any particular model.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Gul Banana posted:

the problem with MVVM is that it's incomplete. it specifies the viewmodel-view decoupled binding process, which is cool, but it doesn't give any indication of where your business logic or service access should live- there's just a vague 'models' layer which doesn't really make sense as you'd rarely want ui sections (v/vm) corresponding 1:1 to data types (m)

I recently gave a talk on MvvmCross and wanted to give an MVVM precursor. This slide contains most of the points I would make:



Basically, MVVM as a UI pattern is really only concerned with the View and ViewModel. It's not so much incomplete as it is open-ended. Do whatever you want with your model, whatever your application or use case requires. The UI paradigm shouldn't affect that.

authwiggidywack
Oct 29, 2013


Might be wrong thread but i'll go for it - anyone here have any MS Certifications? I'm scheduled to take 70-483 Programming in C# at the end of September. About 4-5 years experience.

Was it worth it? Any tips/advice/insight?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

authwiggidywack posted:

Might be wrong thread but i'll go for it - anyone here have any MS Certifications? I'm scheduled to take 70-483 Programming in C# at the end of September. About 4-5 years experience.

Was it worth it? Any tips/advice/insight?

It's incredibly easy. Worth it? Not really.

authwiggidywack
Oct 29, 2013


Ithaqua posted:

It's incredibly easy. Worth it? Not really.

Thanks for the input - are any of the certifications down the line worth getting? I've already paid for this one so I'm just going to get it and be done with it.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

authwiggidywack posted:

Thanks for the input - are any of the certifications down the line worth getting? I've already paid for this one so I'm just going to get it and be done with it.

Not really. I have 4 certs, and I only got them because my company needs to keep X number of people with MCSDs in order to retain our partner status.

Basically, the tests are all horseshit because you can (and most do) download answer dumps and just memorize everything. They are totally meaningless. It might help you get past an HR drone, especially if you have relatively little experience, but no one on the technical side of things will care one way or the other.

authwiggidywack
Oct 29, 2013


Ithaqua posted:

Not really. I have 4 certs, and I only got them because my company needs to keep X number of people with MCSDs in order to retain our partner status.

Basically, the tests are all horseshit because you can (and most do) download answer dumps and just memorize everything. They are totally meaningless. It might help you get past an HR drone, especially if you have relatively little experience, but no one on the technical side of things will care one way or the other.

The answer dumps certainly don't help with the authenticity of the certifications, that is for sure.

Thanks again.

Kekekela
Oct 28, 2004

Ithaqua posted:

Not really. I have 4 certs, and I only got them because my company needs to keep X number of people with MCSDs in order to retain our partner status.


Yeah, I've got the old-school MCSD only because the company I was working for at the time gave us cash bonuses and also time off to study for the tests (lol) so they could keep some partner status. I consider them pretty much pointless and haven't ever gotten the impression that anyone puts much stock in them as far as candidate evaluation.

EssOEss
Oct 23, 2006
128-bit approved
One of the main reasons certifications are useful is that some tenders (especially government tenders) require you to prove that you have N people certified to work with technology X. In this sense hoarding certificates can be good for the company. Often, the same people are listed as the specialist team who will work on every tender because they have the certificates, where in reality they might never even know that such a project existed if the tender were won.

Gul Banana
Nov 28, 2003

Bognar posted:

I recently gave a talk on MvvmCross and wanted to give an MVVM precursor. This slide contains most of the points I would make:



Basically, MVVM as a UI pattern is really only concerned with the View and ViewModel. It's not so much incomplete as it is open-ended. Do whatever you want with your model, whatever your application or use case requires. The UI paradigm shouldn't affect that.

I agree with this & with the other posters who've said something similar- my objection to the name MVVM is that it's unclear (In other uses of "MVC" acronyms the Ms are often a specific thing) and that it doesn't make it plain enough that it's only UI-concerned (again, something like ASP.NET MVC covers control logic as well). So you get a lot of new people confused by how fat their viewmodels should be, how to bind stuff together, etc.

Mr Shiny Pants
Nov 12, 2012

authwiggidywack posted:

Might be wrong thread but i'll go for it - anyone here have any MS Certifications? I'm scheduled to take 70-483 Programming in C# at the end of September. About 4-5 years experience.

Was it worth it? Any tips/advice/insight?

I did this one as well, the problem with it is that it doesn't teach why you do stuff only how to do stuff.

No Safe Word
Feb 26, 2005

Mr Shiny Pants posted:

I did this one as well, the problem with it is that it doesn't teach why you do stuff only how to do stuff.

And it doesn't even really do that because the actual best way to get the cert is the answer dump. Even with a fair amount of experience in the subject area, the tests still have a decent amount of random esoteric crap that you might not have ever encountered.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Has anyone done anything like invite codes/referred codes before? I created a free/unlimited tier for my app for partners, those that will actively promote the app and I was trying to come up with a way that they (or I) can generate an invite code and use that as part of the signup process...I'm asking as I'm a bit lost and don't want to reinvent the wheel.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Uziel posted:

Has anyone done anything like invite codes/referred codes before? I created a free/unlimited tier for my app for partners, those that will actively promote the app and I was trying to come up with a way that they (or I) can generate an invite code and use that as part of the signup process...I'm asking as I'm a bit lost and don't want to reinvent the wheel.

I've always just used Guid.NewGuid(). Use that to generate a URL for referrals, then check for a referring user with that guid during signup.

brap
Aug 23, 2004

Grimey Drawer
Anybody in here have experience with ASP.NET 5 beta apps on Azure? I'm getting chronic, nasty performance issues: 5 to 12 second response times when all I'm doing is reading a string from a Redis cache and shooting it on toward the client. I also get an occasional issue where my API puts out an empty web page instead of JSON. I'm not sure what to try, except maybe to downgrade to the current version of Web API.

RICHUNCLEPENNYBAGS
Dec 21, 2010

Bognar posted:

I've always just used Guid.NewGuid(). Use that to generate a URL for referrals, then check for a referring user with that guid during signup.

That would be my approach too.

fleshweasel posted:

Anybody in here have experience with ASP.NET 5 beta apps on Azure? I'm getting chronic, nasty performance issues: 5 to 12 second response times when all I'm doing is reading a string from a Redis cache and shooting it on toward the client. I also get an occasional issue where my API puts out an empty web page instead of JSON. I'm not sure what to try, except maybe to downgrade to the current version of Web API.

At the risk of sounding like a smartass have you profiled it?

brap
Aug 23, 2004

Grimey Drawer
Honestly not sure. I'm about to get with my friend who's been hosting it using his free azure credit and poke at whatever tools Microsoft provides for profiling a running app. It actually started being responsive at midnight, kept being responsive until a few minutes ago, and is now back at 6 second or so response times.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Does anyone know if the ASP.NET MVC Boilerplate template that's on Visual Studio Gallery is any good? Are there any recommended alternatives?

OneEightHundred
Feb 28, 2008

Soon, we will be unstoppable!
Super low-level question, I'm doing something insane with the .NET Micro Framework and apparently the "stelem" and "ldelem" instructions (specifically, the ones that accept an arbitrary type) aren't supported by it. That seemed weird, so I looked at some disassembled IL and it looks like the C# compiler doesn't emit it even when it could.

Like, if I do this:
code:
MyStruct[] a;
int b;
MyStruct c;
a[b] = c;
... it seems like it could emit:
code:
ldloc.s a
ldloc.s b
ldloc.s c
stelem MyStruct
... but it emits this instead:
code:
ldloc.s a
ldloc.s b
ldelema MyStruct
ldloc.s c
stobj MyStruct
Turning on optimization doesn't affect that, and it has no qualms with emitting the ldelem and stelem variations for primitive types, it just never emits it when it wants to load/store a struct. Is there a reason for that behavior?

OneEightHundred fucked around with this message at 05:03 on Aug 31, 2015

Gul Banana
Nov 28, 2003

every time i release an update to a nuget package, now, my coworkers who're on VS2015 look at me like i shot their dogs :(

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

OneEightHundred posted:

Super low-level question, I'm doing something insane with the .NET Micro Framework and apparently the "stelem" and "ldelem" instructions (specifically, the ones that accept an arbitrary type) aren't supported by it. That seemed weird, so I looked at some disassembled IL and it looks like the C# compiler doesn't emit it even when it could.

...

Turning on optimization doesn't affect that, and it has no qualms with emitting the ldelem and stelem variations for primitive types, it just never emits it when it wants to load/store a struct. Is there a reason for that behavior?

Totally talking out my rear end here, but stelem is specifically for arrays while stobj is for arbitrary memory locations. So, stelem performs a null reference check on the array, checks for out of bounds, and checks for array type mismatch with the stored object. If the compiler can guarantee that all of those are true, it might opt to use stobj instead since fewer runtime checks will mean better performance.

joebuddah
Jan 30, 2005
I am working on a c# program that can add, update and display a table. I am able to get the program to run, enter and display the table. However the update clause is giving me trouble.

code:
public static void AddPat(string id,string name, string location)
       {
           string insStmt = "INSERT INTO PATIENT (Id,Name,Location) VALUES (@id,@name,@location)";
           SqlConnection conn = GetConnection();
           SqlCommand insCmd = new SqlCommand(insStmt, conn);
           insCmd.Parameters.AddWithValue("@id",id);
           insCmd.Parameters.AddWithValue("@name", name);
           insCmd.Parameters.AddWithValue("@location", location);
           try { conn.Open();insCmd.ExecuteNonQuery(); }
           catch (SqlException ex) { throw ex;}
           finally { conn.Close(); }

       }


   public static void UpdatePat(string id, string location)
   {
       string updtCmd = "UPDATE PATIENT WHERE @id = Id SET Locaton = @location (Id,Location) VALUES (@id,@location)";
     
           SqlConnection conn = GetConnection();
       new SqlCommand(updtCmd, conn);
       updtCmd.Parameters.AddWithValue("@id", id);
       updtCmd.Parameters.AddWithValue("@location", location);
       try { conn.Open(); updtCmd.ExecuteNonQuery(); }
       catch (SqlException ex) { throw ex; }
       finally { conn.Close(); }

   }

The errors I am getting are
"string" does not contain a definition for Parameters and "string" does not contain a definition for ExecuteNonQuery(); Thanks in advance for any input or tips.

Dirty Frank
Jul 8, 2004

joebuddah posted:

The errors I am getting are
"string" does not contain a definition for Parameters and "string" does not contain a definition for ExecuteNonQuery(); Thanks in advance for any input or tips.

keep looking at thee 3 lines:

string updtCmd = "UPDATE PATIENT WHERE @id = Id SET Locaton = @location (Id,Location) VALUES (@id,@location)";
SqlConnection conn = GetConnection();
new SqlCommand(updtCmd, conn);

SirViver
Oct 22, 2008
You actually need to use the SqlCommand you created, as you do in AddPat. Currently you're calling ExecuteNonQuery on a string, which obviously can't work.

Also, your SQL update syntax is incorrect. It should be:

UPDATE PATIENT SET Locaton = @location WHERE Id = @id

E: Also, if you just rethrow exceptions, don't use throw ex; but just throw; instead. If you don't do it this way it will create a completely new exception instead of just passing the existing one on, which kills the stack trace information you had on it. Granted, in this case it doesn't really make a difference as the stack trace would point to code inside the SqlConnection, but it's good practice to learn early anyway.

SirViver fucked around with this message at 16:57 on Aug 31, 2015

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Bognar posted:

I've always just used Guid.NewGuid(). Use that to generate a URL for referrals, then check for a referring user with that guid during signup.
Thanks, I ended up going that route, and it was way easier than I thought. Was able to knock it out in a few minutes.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
Having some problems with Simple Injector and PerWebRequest registration. Part of me wonders if I'm understanding DI properly because I'm new to it and this problems feels like a flaw with my entire approach.

I have an MVC project that is utilising a separate library (let's call it RadLib) that I've also developed. RadLib uses dependency injection heavily, and so I've set up all the required wiring in my consuming MVC project. RadLib has what I'm calling a "Session", but it shouldn't be confused with the MVC Session. It's just a basic object that holds the logged in user, some information about their permissions and a session ID, and a few other bits and pieces. The intention is that the session object gets instantiated on every request, and a base controller takes care of checking whether the user is currently logged into an Identity and uses a SessionId Claim to resume the session with RadLib. Any future commands are run though a "SessionValidatorDecorator" to ensure there is a session active and that it's well-formed in various ways.

The way I've done this is to pass around an instance of this session object to the login/resume commands, so that once they've confirmed login or resumption, they populate the session with all the information it needs and then any future uses of that session object for the duration of the web request should have access to that same instance. The problem I'm having is that the logging in and resuming is working fine, but when I send another command the session validation decorator is receiving a new instance of the session object even though it's still the same web request.

I know the above is probably difficult for someone else to understand, but hopefully someone can help me here? The crux of the issue is: I have an object that should be registered PER WEB REQUEST, but for some reason at a seemingly arbitrary point a new instance is created DURING a single web request, so I lose the existing details. Have I misunderstood how per web request works?

putin is a cunt fucked around with this message at 01:25 on Sep 1, 2015

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
This is a particularly hard thing to diagnose without looking at code. From an IoC container perspective, implementing per-request lifetime is dead simple so I wouldn't expect it to be a bug in Simple Injector or anything. Can you post some code from your SessionValidatorDecorator and your IoC wire-up?

Polio Vax Scene
Apr 5, 2009



Trying to transition to visual studio 2015 and it's breaking on exceptions even if it's in a try/catch and even if I have all the exception types unchecked in the exception handler. What gives?

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Bognar posted:

This is a particularly hard thing to diagnose without looking at code. From an IoC container perspective, implementing per-request lifetime is dead simple so I wouldn't expect it to be a bug in Simple Injector or anything. Can you post some code from your SessionValidatorDecorator and your IoC wire-up?

I think the problem is how I was using the resolver, I've managed to fix it now (always the way: struggle with something for days, ask a question about, and the answer arrives immediately!)

ljw1004
Jan 18, 2005

rum

Manslaughter posted:

Trying to transition to visual studio 2015 and it's breaking on exceptions even if it's in a try/catch and even if I have all the exception types unchecked in the exception handler. What gives?

I wonder if turning on "just my code" under tools > options > debugger will help?

Polio Vax Scene
Apr 5, 2009



Already on, unfortunately.

joebuddah
Jan 30, 2005
I got it fixes thanks for all the help

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
How do you guys handle sharing common data to your views in an MVC project? For example, I want a boolean flag that can be accessed in any view that controls whether a particular <div> is shown - how would I do this in a tidy way? I can obviously use ViewBag but I'd like for the data to be strongly typed if at all possible.

Funking Giblet
Jun 28, 2004

Jiglightful!
A base ViewModel with an ActionFilter could do it in a nice transparent way, everything would need to extend from it though. An interface could do the same job also.

Kekekela
Oct 28, 2004
e: nm, I'm not understanding the question.

Kekekela fucked around with this message at 12:42 on Sep 1, 2015

chippy
Aug 16, 2006

OK I DON'T GET IT

Kekekela posted:

Use an @model directive.

With goon naming conventions its something like:

model
code:
public class Dong{public string Butt}
view
code:
@model Dong
...
<div>butt: @Model.Butt</div>
controller
code:
var model = new Dong{Butt="big"};
return View(model);
Typing this on a macbook so apoligies for syntax gaffs but that's the gist.

I think what Funking Giblet wants is some way of having a 'global' boolean variable that any view can have access to, regardless of its actual model type.

Personally I'd probably just add the bool to allrelevant ViewModels.

e: Or use a static class that views can 'ask' but that seems like it might violate some principle or other.

chippy fucked around with this message at 12:33 on Sep 1, 2015

Kekekela
Oct 28, 2004

chippy posted:

I think what Funking Giblet wants is some way of having a 'global' boolean variable that any view can have access to, regardless of its actual model type.

Personally I'd probably just add the bool to allrelevant ViewModels.

e: Or use a static class that views can 'ask' but that seems like it might violate some principle or other.
Motherfuck, I typed half that on my phone before switching to laptop too.
If its just that he wants to access a piece of data that a lot of models need, but doesn't want to put it on the models (or a base class), then he could store it in session and access it from within the view. I think that would be a bad idea on several levels as well as going around your rear end to get to your elbow though, so I'm guessing I just don't understand the issue. :downs:

Kekekela fucked around with this message at 13:23 on Sep 1, 2015

biznatchio
Mar 31, 2001


Buglord

Manslaughter posted:

Trying to transition to visual studio 2015 and it's breaking on exceptions even if it's in a try/catch and even if I have all the exception types unchecked in the exception handler. What gives?

Turn off the option to break on first chance exceptions.

Mr Shiny Pants
Nov 12, 2012
So I have an F# question:

I have an HttpListener that receives a connection and I want this to work with a MailboxProcessor. Logically I want to receive connection --> kick off to a new MailboxProcessor --> be ready for the next request.

What I am wondering about is the overhead of creating a new MailboxProcessor for each new Request coming in.

Should I do this? Or should I create a couple of them and round-robin the Requests between them? Is this stupid? If so why?

This is just something for fun, so I am just wondering. I like the conceptual idea of taking the request --> kicking it off to an Agent --> ready for next request.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
What does your MailboxProcessor do? Does it have any heavyweight dependencies? If it's just an object with a few methods on it and simple dependencies, then that's not gonna be a source of performance problems and pooling them isn't gonna make a significant difference.

What I'd worry more about is your concurrency model. How many requests can be executing at one time, and on how many threads? How does asynchronicity fit in? Too much creation/destruction of threads or even just too many threads can cause performance problems.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply