|
EssOEss posted:A common idiom I use that takes advantage of that is the named constructor, to make it clear and obvious that creating an instance is nontrivial. You could also use the builder pattern here too: code:
xgalaxy fucked around with this message at 16:10 on Nov 4, 2015 |
# ? Nov 4, 2015 16:05 |
|
|
# ? Jun 6, 2024 11:52 |
|
NihilCredo posted:The downside in this case is that you cannot make the constructor private (because the method/s wouldn't have access to it), which is something you want to do if the class isn't supposed to be created by anything other than your method/s. There is no way in C# to make that constructor "accessible only to this one other class", but it's not necessary. Internal fits the bill and comes with the general assumption that you have control of those classes in the same assembly and what they do, which is a reasonable assumption to make.
|
# ? Nov 4, 2015 16:43 |
|
Nitrocat posted:i find the abilities such as converting loops to linq expressions [..] to be vital I don't understand why this is usually named as one of R#'s MVP features. If you find Linq easier to use, why aren't you writing stuff in Linq in the first place, instead of using loops? Vice-versa, if you find it easier to express yourself with loops, why wouldn't you keep them as loops instead of converting them to a form you don't grok as well? I can see the feature being handy when refactoring third-party code, but that shouldn't be an everyday sort of activity, should it?
|
# ? Nov 4, 2015 21:05 |
|
NihilCredo posted:
|
# ? Nov 4, 2015 21:09 |
|
Kekekela posted:I think a lot of people use it as a learning tool, since they initially learned the pre-linq syntax. But yeah, that should be something you do a few times until you get the hang of it. I know a guy who loves R# for exactly this reason.
|
# ? Nov 4, 2015 22:26 |
|
NihilCredo posted:I don't understand why this is usually named as one of R#'s MVP features. LINQ is a decent-sized API all on its own and then a lot of people have written extension libraries for it. I feel pretty comfortable using it but I'm occasionally surprised when R# says I can convert a thing I just wrote.
|
# ? Nov 4, 2015 22:36 |
|
Munkeymon posted:LINQ is a decent-sized API all on its own and then a lot of people have written extension libraries for it. I feel pretty comfortable using it but I'm occasionally surprised when R# says I can convert a thing I just wrote. Sometimes it is nice to leave it as you originally wrote it, rather than have it as a Linq. Sometimes it would produce linq queries that were not exactly easy to see exactly what it was doing just by looking at it. It is handy to have though.
|
# ? Nov 4, 2015 22:38 |
|
Drastic Actions posted:Sometimes it is nice to leave it as you originally wrote it, rather than have it as a Linq. Sometimes it would produce linq queries that were not exactly easy to see exactly what it was doing just by looking at it. It is handy to have though. Oh agreed - I always curate its suggestions. It suggests some janky poo poo in cshtml files sometimes for instace
|
# ? Nov 4, 2015 22:50 |
|
NihilCredo posted:
i don't find my self consistently using either, but I do use it as a learning tool and from that I think that some problems are better solved with linq and others with loops. sometimes i have been surprised when r# notifies me that a loop can be a linq expression. for my personal projects I tend to leave the loops due to how I tend to skim large chunks of code, and having the ability to just glance at a loop and know what it does is handy.
|
# ? Nov 5, 2015 01:53 |
|
Resharper boosts productivity tremendously TBH, especially in huge codebases or when refactoring old/other people's code. This is what I use it for off the top of my head (in no particular order): - Rename (w/ overloads) - Change signature (useful to change method in entire hierarchy) - Move blocks around - Go to next error in file or solution (requires global analysis on) - Find issues in projects (code smells) - Code formatting (way more advanced than what VS offers) - Remove unused references - Apply a fix in entire file/project/solution - Generate constructor - Generate delegating members - Generate missing member implementations - Refactor stuff to use C#6 features - Loop refactoring from/to LINQ - LINQ simplification - Suggest passing of CancellationToken when possible - Go up/down the inheritance hierarchy on a symbol - More advanced 'find usages' - Quickly fix naming in pasted 3rd party code - Removal of redundant code or symbols - Hints when code/symbol isn't used - Simplification of (logical) statements - Pull members up/extract interface - Push members down - Extract method - Inline method/variable - Change signature of caller/callee to match what callee/caller wants - Generate method/class from the way I just tried to use it - Check for null in constructor - Generate and initialize fields from constructor arguments - Static checking annotations: CanBeNull, NotNull, ItemNotNull, ItemCanBeNull, Pure - Code snippets to generate e.g. attached properties, INotifyPropertyChanged etc. - Generate equality members I'm probably forgetting some stuff, but this is what I use daily not just every now and then. So yes, I'd say it's still relevant. VS2015's quick fixes don't even come close.
|
# ? Nov 5, 2015 11:15 |
|
I just discovered GitLink (https://github.com/GitTools/GitLink). Holy poo poo this thing is awesome. It rewrites the pdb to point to the versioned file in Git. No need to run a separate symbol server.
|
# ? Nov 6, 2015 01:10 |
|
What exactly does it do? What is the use case and workflow involved? The readme goes into great depth on command line options but the main point appears to be expressed via a tiny GIF that I cannot understand.
|
# ? Nov 6, 2015 08:53 |
|
That's pretty neat, I had no idea you could even do something like that.EssOEss posted:What exactly does it do? What is the use case and workflow involved? The readme goes into great depth on command line options but the main point appears to be expressed via a tiny GIF that I cannot understand. From what I can tell, it lets you debug into external libraries (e.g. from NuGet) if their code is available on a publicly accessible git repo.
|
# ? Nov 6, 2015 16:08 |
|
Bognar posted:That's pretty neat, I had no idea you could even do something like that. ^^ This. But it can also work with a private repo, within a company for example. It looks like they are adding support for a bunch of different public hosting sites now but the two they have currently support for are GitHub and BitBucket. Honestly feel this is something that should be officially supported by Microsoft. The sources.jar that the JVM world has is very beneficial and is something I've always been kind of jealous that .NET never had a good alternative. This GitLink thing just may be the ticket if it starts seeing wider adoption. xgalaxy fucked around with this message at 16:29 on Nov 6, 2015 |
# ? Nov 6, 2015 16:24 |
|
Code First Existing Database Entity Framework Question I'm using Code First with its fluent type configurations currently. I'd like to transform the following table into the following model. Existing Database: code:
code:
code:
code:
Is this even possible or am I going to need to mess around with extending the Customer and Phone classes to create "proxy" classes and then "newing" properties in the derived types? There's also another issue that phone number values are stuffed in other columns of other tables as well.
|
# ? Nov 7, 2015 00:00 |
|
kingcrimbud posted:Code First Existing Database Entity Framework Question code:
|
# ? Nov 7, 2015 00:11 |
|
You could throw in a computed property for Phones and have your ORM ignore it
|
# ? Nov 7, 2015 01:11 |
|
Inverness posted:Why not simply have Phone, WorkPhone, and CellPhone properties in the Customer class as it is shown in the existing database? The existing database is but one system of several that I need to bring together into a common model. In your example, what if a customer had several cell phones? Why stop at those 3 types of phones? We now have [num of phone type] lists as properties of a customer. I'd prefer one list as a property which is a bit more extensible imo. Sedro posted:You could throw in a computed property for Phones and have your ORM ignore it That's what I was working towards today but it was getting messy with logic in properties, unnecessary inheritance, etc. I wanted to see if I was just completely missing something obvious.
|
# ? Nov 7, 2015 03:04 |
|
Personally, I would start with the database. Have the DBA (or yourself if that's the case) run a procedure to extract the phone #s to another table. Then code to that. Or maybe I missed something with your question? Is the table used in another project that's preventing you from altering it?
|
# ? Nov 7, 2015 03:19 |
|
crashdome posted:Personally, I would start with the database. Have the DBA (or yourself if that's the case) run a procedure to extract the phone #s to another table. Then code to that. I would love to but the table is currently backing an old and not going away anytime soon large support application with a lot of traffic. The question remains; is this a roll-your-own scenario?
|
# ? Nov 7, 2015 06:37 |
|
I would say so. ORMs are no good at doing fanciful "I wish I could fix my tables" style transformations. Use them ONLY for mapping between equivalent data sets, not for converting data into a different format. Or you will be sorry.
|
# ? Nov 7, 2015 11:20 |
|
kingcrimbud posted:The existing database is but one system of several that I need to bring together into a common model. My other choice would be to have a conversion between model classes at the layer where you invoke the ORM. Basically, define the Customer class I posted before as CustomerOldStyle or some relevant name. Write some code to convert that to the new-style Customer class that you want. Likewise when placing new customer objects in the database they would need to be converted to the old style that the ORM understands.
|
# ? Nov 7, 2015 16:14 |
|
I've never used sprocs with EF so this is speculation, but could you perhaps craft one that essentially returned the data as if it were stored using the desired schema, and map the results of that to your object?
|
# ? Nov 7, 2015 19:34 |
|
kingcrimbud posted:I would love to but the table is currently backing an old and not going away anytime soon large support application with a lot of traffic. If your original table is tied to another application and you want more than 3 phone numbers, I don't understand how you are going to do this without yet another table and some weird trickery and shoehorn code tbh. The big problem you are going to run into is when your large support application does an update to a phone number in the original table.
|
# ? Nov 7, 2015 20:59 |
|
I think we might finally be rewriting our monotholic webforms+ext.net project. Has anyone used reactjs+flux with a WebAPI? If so, where did you get started? I know there is a reactjs.net but from what I was reading, no documentation on using flux, etc.
|
# ? Nov 9, 2015 23:17 |
|
Uziel posted:I think we might finally be rewriting our monotholic webforms+ext.net project. Has anyone used reactjs+flux with a WebAPI? If so, where did you get started? I know there is a reactjs.net but from what I was reading, no documentation on using flux, etc. Don't use flux. Use redux (https://github.com/rackt/redux) instead. But this whole discussion is not really .NET related now. Also, you could skip the kool-aid "flux architecture" and instead use RxJS. xgalaxy fucked around with this message at 23:23 on Nov 9, 2015 |
# ? Nov 9, 2015 23:20 |
|
xgalaxy posted:Don't use flux. Use redux (https://github.com/rackt/redux) instead. But this whole discussion is not really .NET related now.
|
# ? Nov 9, 2015 23:22 |
|
Uziel posted:I think we might finally be rewriting our monotholic webforms+ext.net project. Has anyone used reactjs+flux with a WebAPI? If so, where did you get started? I know there is a reactjs.net but from what I was reading, no documentation on using flux, etc. Boy would I hate to be the "which JS framework should we use" decision maker in this day and age. Jesus. <-- Edit: someone tell me why it says Fun Shoe right here epswing fucked around with this message at 23:27 on Nov 9, 2015 |
# ? Nov 9, 2015 23:23 |
|
epalm posted:Boy would I hate to be the "which JS framework should we use" decision maker in this day and age. Jesus. I know. There are so many loving different libraries that do the same poo poo. And they are all wrapped in package manager inception.
|
# ? Nov 9, 2015 23:24 |
|
epalm posted:Boy would I hate to be the "which JS framework should we use" decision maker in this day and age. Jesus.
|
# ? Nov 9, 2015 23:25 |
|
epalm posted:<-- Edit: someone tell me why it says Fun Shoe right here Did you donate to the DB3 memorial fund?
|
# ? Nov 9, 2015 23:36 |
|
Uziel posted:The project would still be in Visual Studio though so wanted to see if there were any gotchas, or specific resources/learning paths for someone familiar with C# Visual Studio and mostly spaghetti style javascript files sprinkled all over a solution. You honestly might want to wait until ASP.NET 5 drops in VS2015. They're adding support for JS task runners, which is basically a necessity when building a React website. We put something together last year that runs the JSX compiler as an MVC Bundler, but overall it was more of a pain in the rear end than I would like.
|
# ? Nov 9, 2015 23:55 |
|
We're doing a major rewrite of an internal tool in react with webapi (mvc6). It's good. I'll write a bit more when I'm off my phone.
|
# ? Nov 10, 2015 01:53 |
|
Bognar posted:You honestly might want to wait until ASP.NET 5 drops in VS2015. They're adding support for JS task runners, which is basically a necessity when building a React website. We put something together last year that runs the JSX compiler as an MVC Bundler, but overall it was more of a pain in the rear end than I would like. uncurable mlady posted:We're doing a major rewrite of an internal tool in react with webapi (mvc6). It's good. I'll write a bit more when I'm off my phone.
|
# ? Nov 10, 2015 03:29 |
|
I would also like to declare my great interest in hearing about your experiences with that!
|
# ? Nov 10, 2015 10:10 |
|
Ok, here's a little bit about our React experience over the past few months. Keep in mind that since this is an internal tool, it's basically just me and another guy working on it, and we don't get a lot of time to work on it because the current version works (but is an unmaintainable horror show). - We (I) decided to use MVC6 because I wanted to break our hard dependency on IIS, and because I'm a rebel, dammit. This has proven to been only a vague pain in the rear end because each ASP.NET 5 beta release has required a few days of refactoring to un-gently caress things that got hosed. I'm still happy that we're using it though, because there's so many things that just make more sense and it'll put us in a good position to break out of the Windows ecosystem once EF7 gets shored up enough to be production ready. I'd definitely wait until the RC1 release this month before starting any 'real' projects, though. - One of the biggest benefits of doing stuff in MVC6 is, honestly, being able to have type-safety and poo poo from the front to the back end. With React, you're tossing most of those benefits away in favor of a clear separation of concerns between the front-end and the back-end. We've settled on sort of a MVVMC thing, where our models and controllers are in ASP.NET (EF6 for the models/ORM, MVC6 WebApi for the controllers) and then React handles view models and views in JS and JSX. - The good news is, if you want to do all of this in VS, you can totally do all of this in VS2015. It supports JS-based task-runners in ASPNET5 projects, so you can set up your JSX->JS converters, your browserify (which lets you write all of your React components and classes in separate files and then combine them later), whatever else you please. You can use Grunt or Gulp to do this, and they're supported in the UI and build process (so you can set pre-build targets, clean targets, etc.) VS2015 also understands JSX syntax, R# 10 will understand JSX, and you can get some intellisense in terms of code completion and whatnot. - The bad? news is stuff you should be girded for - it's Javascript. You're going to have to figure out some way to handle mapping your models into view models. The way we set it up is probably not the best way - we make an initial call to the controller for the data for a page as a bunch of metadata, and then pack that into a top-level view model. Each child component will get some of these properties via their own properties object, and they're responsible for making the calls to populate themselves with the necessary data they need. We use jQuery for most of these AJAX calls. This, looking back, is a mistake - using Flux or Redux or some other form of data store that's meant to integrate with React would have made life easier. That said, it's not awful, it's just kind of annoying because it leads to poor design practices. Consider a simple table. I want to be able to change some element in the table and have that change be reflected back in the DB. To get the data for the table, I essentially get a big ol' JSON blob of key-value pairs, and then have a React component (which is the child of several other react components) that spits out the table row with that data and the other necessary markup. However, I have a problem when I change something in the table. Only the deepest child object knows that the data changed (because React's entire data model is that things flow from parents to children). There's a few ways I can handle this, conceptually - the 'right' way is to have some sort of data store that implicitly sets a callback on a view model and whenever a part of that object changes, it fires off and handles the change however I want. That can be sort of a pain to put together, though, so I opted for the easy/bad way of ensuring that the necessary metadata I need to make the request to change something is passed down along with the data that's being displayed to that innermost child and have it manage the update event. This works fine, don't get me wrong - it can just be hard to keep track of. It's not impossible to debug, however - the React extension for Chrome is very very good and allows you to inspect your properties and state easily enough. If I did it again, I'd use some sort of data store though. - The ugly... is minimal, really. React has pretty good docs and not a whole lot of cruft. You have classes, classes can have children (which are other classes), and you define all of the 'markup' in a render function that allows you to use JSX (which is basically HTML syntax with a few changes that gets converted to actual JS by a JSX converter; it's a one-liner in your gulp file). We decided to organize things into containers and components - a container is a single file that defines a view, and each page you navigate to is a HTML stub that loads that container file into a div. You could also do a SPA with this, we separated it out into pages for... some reason that I can't recall. If you're super comfortable in VS, well, like I said - you can basically stay in VS for quite literally all of this. There's a bunch of other crap I haven't really gotten into that's more React-specific, but the short version is that it's probably less bad than a lot of other things out there like Angular 1 and Knockout and whatever and it works pretty great with VS2015 + ASP.NET 5. If you have any other questions just lemme know or PM me.
|
# ? Nov 11, 2015 00:44 |
I want to make the simplest version of solitaire I can - my main concern right now is the visual aspect of it (least amount of experience). I don't believe the default console has the room for displaying / rendering the board. Should I just go for something popular like MonoGame? Any other alternatives or ideas?
|
|
# ? Nov 11, 2015 01:13 |
|
uncurable mlady posted:Ok, here's a little bit about our React experience over the past few months. Keep in mind that since this is an internal tool, it's basically just me and another guy working on it, and we don't get a lot of time to work on it because the current version works (but is an unmaintainable horror show). Thanks for the write up, that's helpful. I saw that you mentioned you used jquery rather than flux. Is it too late for that now? Did you use reactjs.net (http://reactjs.net/)? Uziel fucked around with this message at 13:35 on Nov 11, 2015 |
# ? Nov 11, 2015 13:25 |
|
Thanks for the interesting writeup! I will be doing some prototyping in the near future and this will serve as a good basis to make the technology decisions. Meanwhile, does anyone here have experience with Windows Nano Server? I tried to get ASP.NET 5 running on it today but could not get anywhere due to DNVM PowerShell installer script actually requiring .NET Framework, which is... not available on Nano Server. Yet I see articles online about people using it, so I wonder if I am missing something.
|
# ? Nov 11, 2015 15:21 |
|
|
# ? Jun 6, 2024 11:52 |
|
Is there something about React I'm not understanding? It seems like the purposeful removable of 2-way data binding just means a lot more boilerplate code for common scenarios. I'm imagining any sort of CRUD app whose purpose is to pull an entity from the DB and let someone make modifications to properties of it on the front-end, then eventually save it back. It seems like to do this with React, you need to make an event handler for every input field tied to a property so you can determine what to do with the change, whereas when I use Knockout, a little hooking up in the DOM and it keeps track of all the changes done on the front-end within a JS object, and then I can write a little function to serialize this object and send it to the server to be updated in the DB on a Save button click or something.
|
# ? Nov 11, 2015 17:28 |