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
Sapozhnik
Jan 2, 2005

Nap Ghost
Use ansible next time

Adbot
ADBOT LOVES YOU

cinci zoo sniper
Mar 15, 2013




Sapozhnik posted:

Use ansible next time

won't it be overkill if i need to launch like 2 system services, open a port or two, and fetch some dependencies for all that jazz? also hopefully i won't have to do much of this any time soon since we're rolly with an external vendor tools to run my models as a rest service

Valeyard
Mar 30, 2012


Grimey Drawer
any shreds of imposter syndrome I had are mostly gone

now that ive actually been working with many people over the last 2 years, and compare myself to them, I have swung in the opposite direction and now im pretty cocky and think im hot poo poo

however whenever i read this thread i always remember that this isnt really the case :negative:

bob dobbs is dead
Oct 8, 2017

I love peeps
Nap Ghost

cinci zoo sniper posted:

won't it be overkill if i need to launch like 2 system services, open a port or two, and fetch some dependencies for all that jazz? also hopefully i won't have to do much of this any time soon since we're rolly with an external vendor tools to run my models as a rest service

alternative: fabric

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


I used the openxml sdk to gently caress with a word document today and I'm glad I could just copy and paste poo poo off the internet to make it work because god drat what the gently caress is the actual structure of this xml supposed to mean?

Shaggar
Apr 26, 2006
the openxml docs are pretty good at describing the schema

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Shaggar posted:

the openxml docs are pretty good at describing the schema

lol if you think I read those and didn't just start banging away at doing stuff

edit: if I'm really lucky I won't have to either because I can get away with just doing a basic find>replace. if I have to style things too then :rip:

Powerful Two-Hander fucked around with this message at 19:52 on Dec 20, 2017

Shaggar
Apr 26, 2006
keep in mind formatting can come at any time including in the middle of a word so your find and replace needs to take that into account.

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Shaggar posted:

keep in mind formatting can come at any time including in the middle of a word so your find and replace needs to take that into account.

yeah I've seen this and am hoping to avoid it


no joke today a company said they had a "special mark up language" for describing documents and templating them it was just tokenised strings with javascript blobbed on the end in brackets

Shaggar
Apr 26, 2006
for templating I like velocity (java) and razor (c#).

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Shaggar posted:

for templating I like velocity (java) and razor (c#).

wait wait wait you can use razor to template office documents??

or just in general for templating because yes razor is good (except when it gets confused about whether you're using code or markup and you have to fiddle around with the @: prefix)

Shaggar
Apr 26, 2006
you can use it to template text documents so I've used it for generating sections in word docs. ive used it for placing content in an existing word doc at placeholder locations but you could just create a razor document.xml and then pack it into a word doc instead.

Shaggar
Apr 26, 2006
like
XML code:
<document>
	<title>@Model.Title</title>
	<paragraph>
		<run>this is my template thank u for reading!</run>
		<run>@Model.somecontent</run>
	</paragraph>
</document>
or w/e idr the exact schema

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


Shaggar posted:

like
XML code:
<document>
	<title>@Model.Title</title>
	<paragraph>
		<run>this is my template thank u for reading!</run>
		<run>@Model.somecontent</run>
	</paragraph>
</document>
or w/e idr the exact schema

o gently caress I am totally going to use this

I never would have thought of using razor like that but I'm already using razor to template elements in the Web ui so creating a parallel set of templates for the models that generates doc chunks should be an easy extension as i can call razor templates in code and inject the render output into the doc

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer
Today I am writing a generic abstract class in java. Like 10 classes will extend it. I feel dirty.

Shaggar
Apr 26, 2006

Powerful Two-Hander posted:

o gently caress I am totally going to use this

I never would have thought of using razor like that but I'm already using razor to template elements in the Web ui so creating a parallel set of templates for the models that generates doc chunks should be an easy extension as i can call razor templates in code and inject the render output into the doc

grab RazorGenerator which provides both a simple library for doing the actual template merge and a VS extension for template handling.

Luigi Thirty
Apr 30, 2006

Emergency confection port.

Valeyard posted:

any shreds of imposter syndrome I had are mostly gone

now that ive actually been working with many people over the last 2 years, and compare myself to them, I have swung in the opposite direction and now im pretty cocky and think im hot poo poo

however whenever i read this thread i always remember that this isnt really the case :negative:

I got Virtual Jaguar building in a VM cross-compiled for Win32 so I can add debug output from the running program (logging bytes written to a specific address out to a file that mimics a debug console) but I still suck rear end at ruby, my day job. ayy lmao

Shaggar
Apr 26, 2006
ask (don't actually ask) me about writing a WPF to convert word templates to velocity. Also a WPF app that allows live editing of velocity templates with live previews created by razor generator as the user types.

jesus WEP
Oct 17, 2004


late to recruiter chat but ive had a guy from CME bugging me about joining them for a while now through linkedin (been working on a fork of their product for a while so i guess that’s how he found me :shrug:)

maybe i’ll go there in a year or so idk

redleader
Aug 18, 2005

Engage according to operational parameters

Shaggar posted:

like
XML code:
<document>
	<title>@Model.Title</title>
	<paragraph>
		<run>this is my template thank u for reading!</run>
		<run>@Model.somecontent</run>
	</paragraph>
</document>
or w/e idr the exact schema

does razor actually escape that poo poo correctly, or does it just do html entity encoding?

redleader
Aug 18, 2005

Engage according to operational parameters
gently caress all computers
gently caress all the web
gently caress all documentation

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Powerful Two-Hander posted:

born to merge
conflict is a gently caress
pull em all 1989
I am Git man
410,757,864,530 squashed commits

please make this shirt

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Notorious b.s.d. posted:

it would be funny to re-implement hg on top of git, sell it as a new improved git cli, and see how many people bite

do this but using libgit2

a great many people will use it

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?
last time I had to implement a mail-merge type thing, I just used textual tokens and RTF

I could get away with that because OpenStep/Cocoa lets you read an RTF document as an NSAttributedString, and any changes you make to the string contents will adjust the formatting attributes appropriately

so our customers could design any layout they wanted as RTF, use some documented {token} strings where they wanted generated information to go, and then point our PoS software at it and we would print pretty receipts

Brain Candy
May 18, 2006

cis autodrag posted:

Today I am writing a generic abstract class in java. Like 10 classes will extend it. I feel dirty.

this is fine you baby

gonadic io
Feb 16, 2011

>>=

cis autodrag posted:

Today I am writing a generic abstract class in java. Like 10 classes will extend it. I feel dirty.

pretend it's an interface. all is good.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

cis autodrag posted:

Today I am writing a generic abstract class in java. Like 10 classes will extend it. I feel dirty.

i did this for a wizard i made. i think if i could do java 8 it would have just been an interface with default methods tho

also what is this SwingUtilities2 and SwingUtilities3 horseshit, oracle?

Shaggar
Apr 26, 2006

redleader posted:

does razor actually escape that poo poo correctly, or does it just do html entity encoding?

it will probably do html encoding since that's what razor's designed for. it will work in most cases but if you have some wonky characters you'll probably need to write your own encoder. You may also be able to tell it not to do any encoding at all so everything is merged into the template as raw strings

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

gonadic io posted:

pretend it's an interface. all is good.

Basically what I'm doing except there's two functions that are identical for all inheriting classes so they're implemented on the super along with the backing data store. It's got two functions, one abstract function, and one field.

It's humming along now and it's actually pretty slick. It's a wrapper to make it easier to mock the really complicated objects we work with.

Soricidus
Oct 21, 2010
freedom-hating statist shill

cis autodrag posted:

Basically what I'm doing except there's two functions that are identical for all inheriting classes so they're implemented on the super along with the backing data store. It's got two functions, one abstract function, and one field.

It's humming along now and it's actually pretty slick. It's a wrapper to make it easier to mock the really complicated objects we work with.

this is acceptable

inheritance is a tool like any other: sometimes bad, sometimes good. so long as you’re thinking about alternatives instead of blindly using the tool you’re most familiar with, you’re probably an ok programmer writing code that’s no worse than anybody else’s

The MUMPSorceress
Jan 6, 2012


^SHTPSTS

Gary’s Answer

Soricidus posted:

this is acceptable

inheritance is a tool like any other: sometimes bad, sometimes good. so long as you’re thinking about alternatives instead of blindly using the tool you’re most familiar with, you’re probably an ok programmer writing code that’s no worse than anybody else’s

Sweet. The environment I came from is vb6 and there anytime a class had a separate interface defined it was pure pain because the debugger sucked and inheritance is weird on vb6

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


data access layer repository design question

say i've got a pod class of some 20 fields that one to one represents a database table , but a developer wants to be able to pull down only three or four relevant fields

should they get the same pod class as everyone else with default values otherwise, a different pod class using the same repo, or a different repo entirely

boss argues should at least get a different pod for performance and memory reasons but i dunno about that

Shaggar
Apr 26, 2006
idk what a pod class is but if you do this it should be a separate model object that represents the same subset that is returned by the existing repository representation.

you should also only do this if theres an actual performance benefit. if the 16 or 17 filtered columns are large and you are returning a lot of rows it could be worth doing.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


pod - plain old data

none of them are large columns, just a bunch of numbers and varchar(20)s mapped to c# decimals and strings respectively

Ciaphas fucked around with this message at 21:38 on Dec 21, 2017

Sapozhnik
Jan 2, 2005

Nap Ghost

Ciaphas posted:

pod - plain old data

none of them are large columns, just a bunch of numbers and varchar(20)s mapped to c# decimals and strings respectively

btw for future reference don't ever use varchar. use text. on postgres at least the two are stored identically but varchar has effectively a check constraint on the length of your input. so you're not optimizing the actual on-disk storage any.

i suspect mssql is similar. at either rate, data validation of this sort does not belong in the database.

Ciaphas
Nov 20, 2005

> BEWARE, COWARD :ovr:


Sapozhnik posted:

btw for future reference don't ever use varchar. use text. on postgres at least the two are stored identically but varchar has effectively a check constraint on the length of your input. so you're not optimizing the actual on-disk storage any.

i suspect mssql is similar. at either rate, data validation of this sort does not belong in the database.

i have 0 control over the db

CPColin
Sep 9, 2003

Big ol' smile.

Shaggar posted:

idk what a pod class is but if you do this it should be a separate model object

Agree with this. Best to make sure everybody understands you're not returning a complete object by making it a different class. Otherwise, somebody's inevitably gonna pass a half-complete object to something that expects a complete object and things will be sad.

Shaggar posted:

you should also only do this if theres an actual performance benefit.

Definitely this. Once you add the extra class, you're now asking developers on your team to think twice every time they need to use this table, because they have to pick which class to use. And when developing some function that uses data from the table, it needs to take an instance of the class that has all the data, the class that has some of the data, or an interface that contains the stuff common to both (and now you have three things to choose from). And God help you if somebody adds a function to the half-complete class that grabs the complete data from the database, because you know somebody's going to do that, instead of just loading all the data to begin with!

NihilCredo
Jun 6, 2011

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

Sapozhnik posted:

i suspect mssql is similar.

it's not

minato
Jun 7, 2004

cutty cain't hang, say 7-up.
Taco Defender
Yeah, seconding that this is premature optimization. Wait until there's a bottleneck, then identify the bottleneck. It might not be what you think.

Assuming there is a performance hit, then there's a few factors to balance:
- is it causing memory pressure? Then a single full-fat object with empty fields might not help that much (unless the empty fields are just pointers). Consider having BaseClass with the essential fields, and FullFatClass extends BaseClass for the full version. Using FullFatClass for the Light version with empty fields is dangerous, because the client needs to be aware at all times that some data is incomplete.

(You can also flip this around: Have a FullFatClass as the base and LightClass extends it, overriding the getter methods to throw exceptions if empty fields are accessed. But that won't save you any memory.)

- API cleanliness. Ideally devs just want a single "getInfo" method to instantiate the class, and not "getLightweightInfo vs getFullFatInfo" or some parameter that specifies light vs full-fat. They don't want to be exposed to the difference. You can achieve this by returning a Proxy or Lazy-loading class, where a single class is returned containing the Light data but it transparently retrieves Full-Fat data if it's ever accessed. The client is unaware of this so the API is cleaner to use, at the expense of a more complex object.

Consider this approach if your dev's ideas about what's essential may change, because you're effectively hiding the definition of Light vs Heavy from them so you can modify the performance without devs modifying their call-sites.

- Also consider that your Dev may really want an aggregate of multiple tables, not just this one. So provide a custom class that gives them exactly what they want and your retrieval API encapsulates the messy work of assembling it efficiently. This gives Devs the API they want while again hiding the concepts of Light vs Heavy from them.

Adbot
ADBOT LOVES YOU

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003

Sapozhnik posted:

btw for future reference don't ever use varchar. use text. on postgres at least the two are stored identically but varchar has effectively a check constraint on the length of your input. so you're not optimizing the actual on-disk storage any.

i suspect mssql is similar. at either rate, data validation of this sort does not belong in the database.

if you have a natural limit on the length of your string, there's nothing wrong with varchar. you're right that in postgres it doesn't give any storage benefit, but data validation of this sort absolutely does belong in the database

  • Locked thread