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
Mr Shiny Pants
Nov 12, 2012

Ithaqua posted:

I grudgingly recommend Stephen Cleary, because he knows asynchrony in .NET inside and out. The grudging is only because he's an evangelical fundamentalist who proselytizes every chance he gets and it really rubs me the wrong way.

I saw him speak at a conference once and he opened up his talk with a bit about how he "knows [he's] going to heaven" which I found really distasteful. It's even in his SO profile.

This is exactly the feeling I got reading his stuff about async.

Adbot
ADBOT LOVES YOU

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
Service bus is a clusterfuck and does not scale well

No Safe Word
Feb 26, 2005

Malcolm XML posted:

Service bus is a clusterfuck and does not scale well

[[citation needed]]

We've run some preliminary performance tests and it has held up okay, what about it doesn't scale well?

rarbatrol
Apr 17, 2011

Hurt//maim//kill.
Yeah, I'd like to hear why. It's shall we say... very relevant to my interests.

Methanar
Sep 26, 2013

by the sex ghost
I'm not sure where to ask this, but it's kind of .NET related (VBA is .NET right?). I have no idea how Excel macros work but I'm trying to make one. If making a macro for this is is dumb then let me know.

I want to iterate through values of X until I find a value that satisfies (X*64)/.75 > Cell to the left. Then I'd like to export the value of X. What would be a good way of doing this?

So far I've got

code:
Dim i As Integer
i = 1
CellToLeft = cell.Offset(0, -1)

Do Until x > CellToLeft
    x = (i * 64) / 0.75
    CellToLeft.Value = x
    i = i + 1
    
Loop

Methanar fucked around with this message at 04:32 on Feb 28, 2016

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

No Safe Word posted:

[[citation needed]]

We've run some preliminary performance tests and it has held up okay, what about it doesn't scale well?

It's based on SQL server internally and has all the issues that brings when dealing with thousands+ events a second especially the whole noisy neighbor thing that wrecks cloud sql

Also some of the guarantees it offers are not easily scaled across data centers and failure domains compared with the relaxed guarantees of azure queues which force you to not rely on them (distributed locking is subtle and hard)

That said u can use it for slow and small data

EssOEss
Oct 23, 2006
128-bit approved
Can you go into more detail?

raminasi
Jan 25, 2005

a last drink with no ice
Well, my program has started consistently crashing with some internal CLR exception when it has a profiler attached :thumbsup:

e: Some obsolete internal exception.

edit edit: I was wrong, it's actually a fatalExecutionEngineError, and it doesn't just happen with a profiler attached. Sometimes my application just crashes for no reason I can determine and I have no idea how to go about solving this. I don't use any unmanaged code myself, and the actual place the problem is occurring (roughly, it's not consistent) isn't near any third-party library calls.

raminasi fucked around with this message at 10:55 on Feb 29, 2016

No Safe Word
Feb 26, 2005

Malcolm XML posted:

It's based on SQL server internally and has all the issues that brings when dealing with thousands+ events a second especially the whole noisy neighbor thing that wrecks cloud sql

Also some of the guarantees it offers are not easily scaled across data centers and failure domains compared with the relaxed guarantees of azure queues which force you to not rely on them (distributed locking is subtle and hard)

That said u can use it for slow and small data

Did you try using express queues/topics? https://azure.microsoft.com/en-us/documentation/articles/service-bus-performance-improvements/#express-queues-and-topics

spiderlemur
Nov 6, 2010
Potentially dumb question from an MVC newbie:

Is there any sort of library that facilitates translating my ViewModels into Repository parameters without breaking the separation? Having a repository method that needs to be called with 30 arguments seems wrong.

I feel like I've heard of something that helps with this translation process rather than a copy/paste mess, but I'm not finding it.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

spiderlemur posted:

Potentially dumb question from an MVC newbie:

Is there any sort of library that facilitates translating my ViewModels into Repository parameters without breaking the separation? Having a repository method that needs to be called with 30 arguments seems wrong.

I feel like I've heard of something that helps with this translation process rather than a copy/paste mess, but I'm not finding it.
I think there is a bit of confusion here.

Your repository parameters would be your model, not view model.

Also, MVC stands for Model-View-Controller. View models are an MVVM concept.

spiderlemur
Nov 6, 2010

Inverness posted:

I think there is a bit of confusion here.

Your repository parameters would be your model, not view model.

Also, MVC stands for Model-View-Controller. View models are an MVVM concept.

I always interpreted NET MVC as MVW for Model-View-Whatever. ViewModels have always been a concept as far as I know, despite the naming.

Regardless, what's the sane way of transferring view data into a Repository from the controller, without calling a repository method with 20 arguments. Passing in the view data (ViewModel) directly seems like it violates the whole separation of concerns thing. On the other hand, it's messy as gently caress.

Maybe I'm just confused on all of this.

crashdome
Jun 28, 2011
Your controller (or view model) would take a model into it, manipulate it, and send it back out to the repository service as needed. Ideally, your parameter for your repository should be a single class model containing all the data it needs.

Che Delilas
Nov 23, 2009
FREE TIBET WEED

spiderlemur posted:

Potentially dumb question from an MVC newbie:

Is there any sort of library that facilitates translating my ViewModels into Repository parameters without breaking the separation? Having a repository method that needs to be called with 30 arguments seems wrong.

I feel like I've heard of something that helps with this translation process rather than a copy/paste mess, but I'm not finding it.

When you run into a "I'm passing 30 arguments" situation, you should be thinking about using an object instead. If that object is a ViewModel, create a method that translates between that object and your Model object, so your repository can do whatever it needs to do with the data. Probably in your Model layer (which can have many layers itself - a detail that is often very poorly explained in MVC guides, if at all). This has the bonus of letting you ignore data the Model doesn't care about.

TLDR: What you're missing is the logic that translates between a ViewModel object and a Model object.

spiderlemur
Nov 6, 2010

crashdome posted:

Your controller (or view model) would take a model into it, manipulate it, and send it back out to the repository service as needed. Ideally, your parameter for your repository should be a single class model containing all the data it needs.

Should the ViewModel (for clarification, what we use for @model in the view) be passed into the repository directly, or should there be a container class in the middle which data is transferred to before being passed into the repository?

Edit: above post answers my question, thanks!

Wardende
Apr 27, 2013
I'm about to start building a PoC for a message-queue architecture. Is Mass Transit worth using, or should I write against the RabbitMQ/Azure/etc. APIs directly?

Essential
Aug 14, 2003
I got hit with a leap year bug today. I was creating a new DateTime object like so:

code:
LastYearToDate = new DateTime(DateTime.Today.AddYears(-1).Year, DateTime.Today.Month, DateTime.Today.Day);
Didn't think that one thru all the way...

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

no because they were really new and even then have limits and its unclear how the nodes coordinate in the partitions

it's just a lot simpler to write a load balanced layer over the azure queue than to deal w/ the complexity of service bus

Queues can go a long long way with minimal abstractions

looks to be ok for smallish stuff tho

MajorBonnet
May 28, 2009

How did I get here?

Methanar posted:

I'm not sure where to ask this, but it's kind of .NET related (VBA is .NET right?). I have no idea how Excel macros work but I'm trying to make one. If making a macro for this is is dumb then let me know.

I want to iterate through values of X until I find a value that satisfies (X*64)/.75 > Cell to the left. Then I'd like to export the value of X. What would be a good way of doing this?

So far I've got

code:
 Code...

You shouldn't need to iterate to solve this. You have the value of the cell to the left, so re-write the equation for X:
code:
X > (Y *0.75) / 64
And X should be:
code:
INT((Y*0.75) / 64) + 1
as an Excel formula.

EDIT because I don't know Excel functions...

MajorBonnet fucked around with this message at 00:51 on Mar 1, 2016

B-Nasty
May 25, 2005

Wardende posted:

I'm about to start building a PoC for a message-queue architecture. Is Mass Transit worth using, or should I write against the RabbitMQ/Azure/etc. APIs directly?

Which is better, a truck or a motorcycle?

I, personally, don't like adding complexity unless I think I'm going to need it. If you just need a simple fire-forget/pickup-execute type arrangement, Azure Queue or Rabbit would be fine. Serialize a class holding your desired action and config to the proper queue (JSON or XML), and long-poll to find work to do in your service. Rabbit is far more feature-rich than Azure queues, so even that might be overkill.

MassTransit is pretty well documented; I'd do a quick read-through and see if the concepts seem like something you'd make use of. If not, I don't think the abstraction is worth it.

Inverness
Feb 4, 2009

Fully configurable personal assistant.

B-Nasty posted:

Which is better, a truck or a motorcycle?
Well one has a much higher chance of keeping you alive. :v:

xgalaxy
Jan 27, 2004
i write code
Jet Brains C# IDE is out for early access (aka beta). I'm excited to check it out. While running Visual Studio on OS X via parallels is an okay experience it would be nice to have something that offers a bit of a smoother ride performance wise. I hate MonoDevelop. I've used IntelliJ before and loved it for Java programming.

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

Ithaqua posted:

You shouldn't do either of those in a web application since long-running threads are subject to arbitrary cancellation by the web server.

Bognar posted:

That's not what async/await is for, and you could accomplish that task without async/await. However, I would still recommend using the database or a durable queue for email. For one, it makes it much easier to implement retry logic for when the email inevitably has a transient failure for one reason or another. Plus it gives you a nice place to store potential exceptions related to sending that email. Sure you could do all of this in-process and with log statements, but email is finicky enough that it's useful to have a single table aggregating all this information.

Also, as Ithaqua said, there's no guarantee that code will continue to execute once it is detached from a Request in ASP.NET (e.g. if the Request is closed before your email is sent - exactly what you're trying to accomplish).

Yeah I definitely understand that there's a better way to do this, but the time pressure is on and the emails are not in the slightest bit critical so this is a good stop-gap until we can organise a more wholistic solution. I agree that an email queue is the way to go but this is software that companies can purchase to host themselves and the more bits and pieces we have going on the more complicated the ongoing support becomes.

That's not to say I won't be taking this approach, just that it requires a thoughtful implementation, far more thought than I have the time for since the success of the email really doesn't matter too much. I've noted this particular bit of technical debt and I don't plan on leaving it this way.

22 Eargesplitten
Oct 10, 2010



Are the styling conventions for C# similar to Java? I'm going through one of the Unity 3D tutorials, and the script he's writing works, but the formatting seems way off. Here's what he's written.

code:
	private Rigidbody rb;
	void Start ()
	{
		rb = GetComponent<Rigidbody> ();
	}
		
	void fixedUpdate ()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);

		rb.AddForce (movement);
	}
I feel like instead it should be

code:
	private Rigidbody rb;
	
	void Start()	{
		rb = GetComponent<Rigidbody>();
	}
		
	void fixedUpdate(){
		float moveHorizontal = Input.GetAxis("Horizontal");
		float moveVertical = Input.GetAxis("Vertical");
		Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

		rb.AddForce(movement);
	}
Which is right?

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

22 Eargesplitten posted:

Which is right?

Generally Allman style (the one from Unity) because it is Microsoft's default within Visual Studio. Programmers Stackexchange has some info on it and why it might be.

Be consistent is most important but if you want K&R style braces you are going to be fighting an uphill battle against Visual Studio defaults

NihilCredo
Jun 6, 2011

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

22 Eargesplitten posted:

Are the styling conventions for C# similar to Java? I'm going through one of the Unity 3D tutorials, and the script he's writing works, but the formatting seems way off. Here's what he's written.

Which is right?

Allman style (= vertically aligned braces) is the de facto standard for C#, while K&R style (= first brace at the end of the line) is indeed more common in Java.

You can use whichever style looks better to you, though. Serious programmers rarely have strong opinions about braces/indentation and are unlikely to make a big deal out of it.

No Safe Word
Feb 26, 2005

gariig posted:

Generally Allman style (the one from Unity) because it is Microsoft's default within Visual Studio. Programmers Stackexchange has some info on it and why it might be.

Be consistent is most important but if you want K&R style braces you are going to be fighting an uphill battle against Visual Studio defaults

It's not difficult at all to tell Visual Studio to format things differently. But having it consistently actually follow the rules you set, on the other hand, is indeed an uphill battle.

Of note, in 22 Eargesplitten's example, the default Visual Studio style actually doesn't put spaces between function names and the parens for the args. So that looks like a custom style rule being applied.

You can change it in the Text Editor settings for each language under Tools > Options

xgalaxy
Jan 27, 2004
i write code
The Unity3d version of MonoDevelop defaults to putting spaces around the parenthesis. And for whatever stupid loving reason whenever you regenerate the Unity3d MonoDevelop project it resets these settings back to default. Making it virtually impossible to have it set to a style you actually prefer.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

xgalaxy posted:

The Unity3d version of MonoDevelop defaults to putting spaces around the parenthesis. And for whatever stupid loving reason whenever you regenerate the Unity3d MonoDevelop project it resets these settings back to default. Making it virtually impossible to have it set to a style you actually prefer.

Don't blame monodevelop itself. Unity forked mono and monodevelop and they are early versions. A lot of issues get fixed in the new versions and Xamarin Studio and don't get backported.

Except for this one, I think it's still in Xamarin studio. :v:

Edit: not saying you were, but I've gotten people telling me issues in MD that are in the unity version, and don't know the difference.

22 Eargesplitten
Oct 10, 2010



Okay, thanks. Allman style is what I was taught in C++ class, but I thought it was just outdated.

Is there any way to use another IDE for unity by default? I also don't like how there is apparently no way to make it show column numbers.

RICHUNCLEPENNYBAGS
Dec 21, 2010

No Safe Word posted:

It's not difficult at all to tell Visual Studio to format things differently. But having it consistently actually follow the rules you set, on the other hand, is indeed an uphill battle.

Of note, in 22 Eargesplitten's example, the default Visual Studio style actually doesn't put spaces between function names and the parens for the args. So that looks like a custom style rule being applied.

You can change it in the Text Editor settings for each language under Tools > Options

I use a configuration in ReSharper and an extension that runs a ReSharper format on the current file on save. It works OK.

crashdome
Jun 28, 2011

22 Eargesplitten posted:

Okay, thanks. Allman style is what I was taught in C++ class, but I thought it was just outdated.

:eng101: They're both actually about the same age!

:pseudo: Using/Reading K&R is known to cause tumors!

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

22 Eargesplitten posted:

Which is right?

Neither. It should be:

C# code:
    private Rigidbody _rb;

    private void Start ()
    {
        _rb = GetComponent<Rigidbody>();
    }

    private void FixedUpdate ()
    {
        var moveHorizontal = Input.GetAxis("Horizontal");
        var moveVertical = Input.GetAxis("Vertical");
        var movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        _rb.AddForce (movement);
    }
Style rules followed were:

1. Explicitly labeled accessibility modifiers.
2. Use var.
3. Capitalize method names.
4. Prefix private fields with _.
5. Don't use the goofy space between method and parentheses.
6. Allman-style braces.
7. Spaces > tabs

(but seriously, pick a style and just be consistent with it)

Bognar fucked around with this message at 15:51 on Mar 3, 2016

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Bognar posted:

Neither. It should be:

C# code:
    private Rigidbody _rb;

    private void Start ()
    {
        _rb = GetComponent<Rigidbody>();
    }

    private void FixedUpdate ()
    {
        var moveHorizontal = Input.GetAxis("Horizontal");
        var moveVertical = Input.GetAxis("Vertical");
        var movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

        _rb.AddForce (movement);
    }
Style rules followed were:

1. Explicitly labeled accessibility modifiers.
2. Use var.
3. Capitalize method names.
4. Prefix private fields with _.
5. Don't use the goofy space between method and parentheses.
6. Allman-style braces.
7. Spaces > tabs

(but seriously, pick a style and just be consistent with it)

ehh dont use var unless the type is redundant

it's lot easier to understand the code when u dont have to do hindley-milner++ in your head

epswing
Nov 4, 2003

Soiled Meat

Bognar posted:

Neither. It should be:

C# code:
    private void FixedUpdate ()
Style rules followed were:

5. Don't use the goofy space between method and parentheses.

Typo?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



22 Eargesplitten posted:

Okay, thanks. Allman style is what I was taught in C++ class, but I thought it was just outdated.

Is there any way to use another IDE for unity by default? I also don't like how there is apparently no way to make it show column numbers.

That is indeed a really stupid default but it's easier to enable globally in settings than to use a different IDE. Options > Text Editor > All Languages

brap
Aug 23, 2004

Grimey Drawer
Hover with the mouse cursor over var to see its type. Or press dot on the value to see if it has the stuff you want. I use var whenever the compiler allows it. The important part is that you're getting type checking. You know you're calling methods that exist in permitted ways and that you're returning the right types. I think var tends to reduce the effort of superficial refactors.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

fleshweasel posted:

Hover with the mouse cursor over var to see its type. Or press dot on the value to see if it has the stuff you want. I use var whenever the compiler allows it. The important part is that you're getting type checking. You know you're calling methods that exist in permitted ways and that you're returning the right types. I think var tends to reduce the effort of superficial refactors.

cool having

var x = f(1)
.
.
.
var y = g(x)

etc etc is basically awful to keep poking through

just use it when the type is basically obvious and avoid it when the type would also add to documentation for the next person to inspect your code not using VS (gh code review, for example).

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

https://en.wikipedia.org/wiki/Muphry%27s_law

Adbot
ADBOT LOVES YOU

Calidus
Oct 31, 2011

Stand back I'm going to try science!
I have a Solution that contains a MVC 5 project, a business logic project and DAL project. When I try use the MVC scaffolding with my entity frame work objects in my DAL project I keep getting “Object reference not set to an instance of an object.” The MVC project has a reference to my DAL project. I tried creating a test db context inside my MVC project and I got the same error. This is driving me up a wall. I am using VS2013.

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